php - Magento filter collection by attribute option -


this question has answer here:

i'm pretty new magento , i'm trying figure out how filter collection of products. here's situation: have product have 'style', product's attribute (example of style: brass). need other products have style 'brass'.

i've done few research , discovered addfieldtofilter() method, doesn't seem working (or, likely, i'm not using properly):

$same_style_collection = mage::getmodel('catalog/product')->getcollection()     ->addfieldtofilter(array(array('attribute' => 'name', 'like' => 'brass'))); 

can me? appreciated.

have tried this?

$collection = mage::getmodel('catalog/product')     ->getcollection()     ->addattributetofilter('style', 'brass'); 

this give products have attribute style value brass.

when want filter data eav collection use addattributetofilter, , when want filter data flat table collection use addfieldtofilter.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -