Jump to content
crespim

[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));
shuffle($products);
$products = array_slice($products, 0, ($nb ? $nb : 10));
$smarty->assign(array(
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize('home')));

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

 

http://customizarts.com.br/loja/

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.

 

Falow

Edited by FelipeGallo

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

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

×

Important Information

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