Jump to content

Random featuredproducts block


Recommended Posts

Am pus, uite cum arata:

 

 

public function hookDisplayHome($params)

                {

                               if (!$this->isCached('homefeatured.tpl', $this->getCacheId('homefeatured')))

                               {

                                               $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);

                                               $nb = (int)Configuration::get('HOME_FEATURED_NBR');

                                               $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), "position");

shuffle($products);

print_r($products);

                                               $this->smarty->assign(array(

                                                               'products' => $products,

                                                               'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),

                                                               'homeSize' => Image::getSize(ImageType::getFormatedName('home')),

                                               ));

                               }

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

                }

 

 

Site-ul este www.ncp.ro/presta. La PRODUSE RECOMANDATE vreau sa aplic aceasta functie random.

Link to comment
Share on other sites

Dupa ce am salvat codul cum mi-ai zis tu la primul refresh pe pagina mi-a aparut textul, codul. La urmatorul mi-a arata pagina OK cu produsele acelea 8 aranjate un pic altfel. Dar acum nu se mai schimba la refresh.

 

La fiecare refresh imi arata produsele in aceasi ordine.

Am observat ca daca nu sunt logat sunt aranjate altfel, dar aceleasi produse.

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...