Jump to content

[resolvido]Home com produtos aparecendo aleatoriamente.

Recommended Posts

Usei na 1.5.6...

public function hookDisplayHome($params)
global $smarty;

$category = new Category(Context::getContext()->shop->getCategory(), Configuration::get('PS_LANG_DEFAULT'));
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10));
$products = array_slice($products, 0, ($nb ? $nb : 10));
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize('home')));

return $this->display(__FILE__, 'homefeatured.tpl');



Share this post

Link to post
Share on other sites

Em qual arquivo vc usou esse código?


EDIT: Achei aqui, é no homefeatured.php, só inserir o shuffle($products);


Shuffle serve para combinar aleatóriamente valores de um array.



Edited by FelipeGallo (see edit history)

Share this post

Link to post
Share on other sites

Bom dia, pessoal.

Pra mim ate deu certo na versao que uso 1.5.6 mas fica randomicamente somente os produtos de uma categoria.. minhas outras categorias nao aparecem.. alguem sabe o que pode ser??

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More