Sharak Posted July 3, 2014 Share Posted July 3, 2014 Custom module. I can get specific category's products: $category = new Category((int)$this->product_type_menu, Configuration::get('PS_LANG_DEFAULT')); $this->product_list = $category->getProducts((int)($cookie->id_lang), 1, $nb); I also can get specials: $this->product_list = Product::getPricesDrop((int)($cookie->id_lang), 0, $nb); But how to get specials from a specific category? Link to comment Share on other sites More sharing options...
Sharak Posted July 7, 2014 Author Share Posted July 7, 2014 Any suggestions? Link to comment Share on other sites More sharing options...
vekia Posted July 7, 2014 Share Posted July 7, 2014 in simple words: it's not possible by default of course. it is possible but only with modification of the sql query / php function in funciton argument add new one $category and in php code with query add left join LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) and in WHERE clause add where cp.`id_category`=$category (new function argument) Link to comment Share on other sites More sharing options...
Sharak Posted July 7, 2014 Author Share Posted July 7, 2014 (edited) Can I use Context:: instead query changing? Should be simpler this way, but I don't know how to make it work... Edited July 7, 2014 by Sharak (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted July 7, 2014 Share Posted July 7, 2014 without changing / creating new funciton to get products it will not be possible. function like you want just doesnt exist, so you have to create it. no matter where, it can be created in product class, context class, XXXX classs etc Link to comment Share on other sites More sharing options...
Sharak Posted July 29, 2014 Author Share Posted July 29, 2014 (edited) in funciton argument add new one $category and in php code with query add left join LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) and in WHERE clause add where cp.`id_category`=$category (new function argument) Actually I don't want to join with specific category as this one is set through module configuration. I need to join with pricedrops but I can't make it work. For now I just used simple condition in .tpl to show only products with reduction price set: {foreach from=$tab->product_list item=product name=product_list} {if $product.reduction > 0} <li>Product specifics</li> {/if} {/foreach} Edited July 29, 2014 by Sharak (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts