Jump to content

Mover módulo Product In The Same Category a TOP


djmortis

Recommended Posts

Buenas, desde el Live Edit estoy intentando mover el módulo de Product in the same category arriba de la info del producto en si, vamos, en el TOP y no me deja.

 

¿Como puedo poner ese módulo o cualquiera en dicha posición?

 

Gracias.

Link to comment
Share on other sites

Buenas: Tienes que registrarlo; 

 

Te explico:

 

Abres modulos/productscategory/productscategory.php

 

Buscas y pones abajo de esta lista

return (parent::install()
&& $this->registerHook('productfooter')
&& $this->registerHook('header')
&& $this->registerHook('addproduct')
&& $this->registerHook('updateproduct')
&& $this->registerHook('deleteproduct')
&& $this->registerHook('displaytopcolumn')
 
 
Despues copias toda la funcion de mostrar los productos en el productfooter y le cambias el hook, lo puedes pegar todo el tocho justo encima del original, cuidado con los corchetes de apertura y cierre
 
public function hookDisplayTopColumn($params)
{
$id_product = (int)$params['product']->id;
$product = $params['product'];
 
$cache_id = 'productscategory|'.$id_product.'|'.(isset($params['category']->id_category) ? (int)$params['category']->id_category : (int)$product->id_category_default);
 
if (!$this->isCached('productscategory.tpl', $this->getCacheId($cache_id)))
{
 
$category = false;
if (isset($params['category']->id_category))
$category = $params['category'];
else
{
if (isset($product->id_category_default) && $product->id_category_default > 1)
$category = new Category((int)$product->id_category_default);
}
 
if (!Validate::isLoadedObject($category) || !$category->active)
return false;
 
// Get infos
$category_products = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */
$nb_category_products = (int)count($category_products);
$middle_position = 0;
 
// Remove current product from the list
if (is_array($category_products) && count($category_products))
{
foreach ($category_products as $key => $category_product)
{
if ($category_product['id_product'] == $id_product)
{
unset($category_products[$key]);
break;
}
}
 
$taxes = Product::getTaxCalculationMethod();
if (Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE'))
{
foreach ($category_products as $key => $category_product)
{
if ($category_product['id_product'] != $id_product)
{
if ($taxes == 0 || $taxes == 2)
{
$category_products[$key]['displayed_price'] = Product::getPriceStatic(
(int)$category_product['id_product'],
true,
null,
2
);
} elseif ($taxes == 1)
{
$category_products[$key]['displayed_price'] = Product::getPriceStatic(
(int)$category_product['id_product'],
false,
null,
2
);
}
}
}
}
 
// Get positions
$middle_position = (int)round($nb_category_products / 2, 0);
$product_position = $this->getCurrentProduct($category_products, (int)$id_product);
 
// Flip middle product with current product
if ($product_position)
{
$tmp = $category_products[$middle_position - 1];
$category_products[$middle_position - 1] = $category_products[$product_position];
$category_products[$product_position] = $tmp;
}
 
// If products tab higher than 30, slice it
if ($nb_category_products > 30)
{
$category_products = array_slice($category_products, $middle_position - 15, 30, true);
$middle_position = 15;
}
}
 
// Display tpl
$this->smarty->assign(
array(
'categoryProducts' => $category_products,
'middlePosition' => (int)$middle_position,
'ProdDisplayPrice' => Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE')
)
);
}
 
return $this->display(__FILE__, 'productscategory.tpl', $this->getCacheId($cache_id));
}

 

 

Despues te vas aposiciones de modulos/ insertar un hook y lo enganchas Productos en la misma categoria en ese hook

 

Para que salga en la ficha de producto arriba tendras que meter donde consideres en product.tpl

{hook h='displayTopColumn'}

Link to comment
Share on other sites

Hago lo que me has indicado y me salta lo siguiente:

 

Notice: Undefined index: product in /modules/productscategory/productscategory.php on line 110

Notice: Trying to get property of non-object in /modules/productscategory/productscategory.php on line 110

Notice: Undefined index: product in /modules/productscategory/productscategory.php on line 111

Notice: Trying to get property of non-object in /modules/productscategory/productscategory.php on line 113

 

Esas línas contienen lo siguiente:

$id_product = (int)$params['product']->id;
$product = $params['product'];
 
$cache_id = 'productscategory|'.$id_product.'|'.(isset($params['category']->id_category) ? (int)$params['category']->
Link to comment
Share on other sites

Al posicionar el modulo en ese hook es posible que tengas que instanciar los objetos ( product, category) de manera diferente.

Si no quieres complicarte demasiado puedes hacerlo con jquery, en el archivo:

themes\tu_tema\js\product.js

en la parte de

$(document).ready(function()

añade por ejemplo esto (plantilla default)

$('.page-product-box.blockproductscategory').insertBefore('.breadcrumb');

El resultado utilizando la plantilla default seria el que aparece en la imagen adjunta

post-107989-0-50598600-1467484147_thumb.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...