muynck Posted March 16, 2014 Share Posted March 16, 2014 (edited) I made my very first plugin , however, I want to show all products in a .tpl. So far it wasn't a problem in the php-file I made. But i really want to manipulate it through a controller, as recommended. It ALMOST works, I found a snippet with this: $this->context->smarty->assign( 'products', $this->context->cart->getProducts() ); $this->setTemplate('details.tpl'); This shows all products in the cart... not exactly what I need. Who can help me change this in to all products available in the shop? I have another snippet that works fine with a php file and a template, maybe it helps: $this->context->smarty->assign(array( 'products' => Product::getNewProducts(intval($cookie->id_lang), 0, 100000, false, $orderBy, $orderWay) ) ); I set the limit to 100,000, if you know another way, more professional, please let me know. Help would be very appreciated. Edit: PS 1.5 Edited March 16, 2014 by muynck (see edit history) Link to comment Share on other sites More sharing options...
loulou66 Posted March 16, 2014 Share Posted March 16, 2014 (edited) hi for PS 1.5.6.1 you have one function in classes=>product.php /** * Get all available products * * @param integer $id_lang Language id * @param integer $start Start number * @param integer $limit Number of products to return * @param string $order_by Field for ordering * @param string $order_way Way for ordering (ASC or DESC) * @return array Products details */ public static function getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false,$only_active = false, Context $context = null) then for all products $id_lang = (int)$this->context->language->id; $limit =0; $products =array(); $products = product::getProducts($id_lang,$limit); $this->context->smarty->assign(products; $products); $limit = 0; => all products for your tpl you can adapt the product-list.tpl of your theme and the product_list.css @++ loulou66 Edited March 16, 2014 by loulou66 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted March 16, 2014 Share Posted March 16, 2014 remember that this feature can affect performance, especially when you will have a lot of products Link to comment Share on other sites More sharing options...
muynck Posted March 16, 2014 Author Share Posted March 16, 2014 @loulou66 Your code seems very plausible, but it still doesn't work. I had a lot of scripts alike. This is the full code now, which gives a blanc page: if (!defined('_PS_VERSION_')) exit; class alphabetDetailsModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $id_lang = (int)$this->context->language->id; $limit =0; $products =array(); $products = product::getProducts($id_lang,$limit); $this->context->smarty->assign(products; $products); $this->setTemplate('details.tpl'); } } @vekia I'm fully aware of that. I really want to show all products on one page. It will be somewhere around 300 products. I'm thinking about loading it with AJAX after scrolling... But first get the whole list Link to comment Share on other sites More sharing options...
loulou66 Posted March 18, 2014 Share Posted March 18, 2014 Hi look last message of this post not tested with 300 products tell me that work fine http://www.prestashop.com/forums/topic/273904-show-all-products-in-prestashop-155/page-2?do=findComment&comment=1598172 @++ loulou66 Link to comment Share on other sites More sharing options...
loulou66 Posted March 19, 2014 Share Posted March 19, 2014 HI i found an another solution without new module http://www.prestashop.com/forums/topic/316178-all-product-on-fo/ i try to corrige the module for probleme with pagination @++ Loulou66 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