Magento Filter Products By Attribues AND Tag -


i'm trying filter collection of products based on 2 custom attributes , tag, can filter custom attributes with:

$products   = mage::getmodel('catalog/product')->getcollection();  $products->addattributetoselect('name'); $products->addattributetofilter('custom_attribute1' , 50); $products->addattributetofilter('custom_attribute2' , 20); 

however when try extend filter using tag:

$products->jointable         (             array( 'relation'=>'tag/relation' ),                 "relation.product_id = e.entity_id , relation.tag_id = '82'"         ); 

i following message:

php fatal error:  uncaught exception 'mage_eav_exception' message 'invalid joint fields' 

any idea how can products match conditions (custom attributes , tag), thanks!!

try this:

$products->getselect()->join(     array('relation' => $products->gettable('tag/relation')),     "relation.product_id = e.entity_id , relation.tag_id = '82'" ); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -