{"id":57,"date":"2010-09-28T03:54:00","date_gmt":"2010-09-28T03:54:00","guid":{"rendered":"http:\/\/www.codeboss.in\/web-funda\/?p=57"},"modified":"2010-09-28T03:54:00","modified_gmt":"2010-09-28T03:54:00","slug":"magento-load-a-product-by-any-attribute","status":"publish","type":"post","link":"https:\/\/codeboss.in\/web-funda\/2010\/09\/28\/magento-load-a-product-by-any-attribute\/","title":{"rendered":"Magento &#8211; Load A Product By Any Attribute"},"content":{"rendered":"<p>While generally we load a product in Magento by its<i><b> id<\/b><\/i>, it is also possible to load it by any of its attribute. To do that use the following code &#8211;<\/p>\n<pre class=\"brush: php\">$_p =&nbsp;Mage::getModel('catalog\/product')-&gt;loadByAttribute('attr_name',&nbsp;$attrib);<br \/><\/pre>\n<p>Just replace &#8216;attr_name&#8217; with the name of the attribute and $attrib with the value and then Magento will fetch matching products.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While generally we load a product in Magento by its id, it is also possible to load it by any of its attribute. To do that use the following code &#8211; $_p =&nbsp;Mage::getModel(&#8216;catalog\/product&#8217;)-&gt;loadByAttribute(&#8216;attr_name&#8217;,&nbsp;$attrib); Just replace &#8216;attr_name&#8217; with the name of the attribute and $attrib with the value and then Magento will fetch matching products.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[54,57],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-magento","tag-php","entry"],"_links":{"self":[{"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":0,"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeboss.in\/web-funda\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}