Jump to content

Getting specials from specific category


Recommended Posts

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

in simple words: it's not possible :D

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

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

  • 4 weeks later...

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 by Sharak (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...