web_br Posted May 2, 2011 Share Posted May 2, 2011 Hi,I just want to modify the query that returns the products to be displayed in product-list.tpl. In, classes/Product.php, I did find and modify the query for new products (getNewProducts) but... where is the REAL getProducts function? If I change anything in getProducts, no change at all... even if I change the name of the function... no error whatsoever... Am I missing something here? Thanks Link to comment Share on other sites More sharing options...
JohnDoe5268 Posted May 20, 2011 Share Posted May 20, 2011 I have the same problem, does anyone knows where find this variable ? Link to comment Share on other sites More sharing options...
web_br Posted May 20, 2011 Author Share Posted May 20, 2011 Hi John ;-)I finally found the method to get category products in classes/Category (getProducts) Link to comment Share on other sites More sharing options...
gonandriy Posted May 20, 2011 Share Posted May 20, 2011 Can you provide link on page with products list? Link to comment Share on other sites More sharing options...
web_br Posted May 20, 2011 Author Share Posted May 20, 2011 Not sure I'm following you... Link to comment Share on other sites More sharing options...
gonandriy Posted May 20, 2011 Share Posted May 20, 2011 Not need. if you already found solution. Link to comment Share on other sites More sharing options...
JohnDoe5268 Posted May 20, 2011 Share Posted May 20, 2011 Thanx In fact, I search where is the $products variable defined, but i'dont find it in the getProducts function :/ Link to comment Share on other sites More sharing options...
web_br Posted May 20, 2011 Author Share Posted May 20, 2011 It is defined in the Category Controller around line 140 : self::$smarty->assign(array('products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, Link to comment Share on other sites More sharing options...
JohnDoe5268 Posted May 20, 2011 Share Posted May 20, 2011 Ho dude it's right By the way, do you know how to shuffle this array in another ? I've tried this but it doesn't work : self::$smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, //The new array 'products_rand' => shuffle((isset($cat_products) AND $cat_products) ? $cat_products : NULL), 'id_category' => (int)($this->category->id), 'id_category_parent' => (int)($this->category->id_parent), 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int)($this->category->id)), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home') )); Link to comment Share on other sites More sharing options...
web_br Posted May 20, 2011 Author Share Posted May 20, 2011 isset($cat_products) AND $cat_products will return a boolean not an array. Try to shuffle the $cat_products variable before it is assigned to $smarty Link to comment Share on other sites More sharing options...
JohnDoe5268 Posted May 20, 2011 Share Posted May 20, 2011 And I recall it by the same way ? Like this ? $cat_products_rand = shuffle($cat_products); self::$smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'products_rand' => (isset($cat_products_rand) AND $cat_products_rand) ? $cat_products_rand : NULL, 'id_category' => (int)($this->category->id), 'id_category_parent' => (int)($this->category->id_parent), 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int)($this->category->id)), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home') )); Link to comment Share on other sites More sharing options...
web_br Posted May 20, 2011 Author Share Posted May 20, 2011 Yes. Now your shuffled array will be available in your .tpl file. {$products_rand} Link to comment Share on other sites More sharing options...
JohnDoe5268 Posted May 20, 2011 Share Posted May 20, 2011 It will shuffle $cat_products, but i've find the solution : I had just to declare $cat_products_rand in two steps : $cat_products_rand = $cat_products; shuffle($cat_products_rand); Thanks for your help web_br ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now