0

I want to get a product by sku, when i do from the admin area in manage products, i got a result but i noticed that magento stores the sku with two zeros added at the begging of the number. The problem is when i try to the same programmatically using :

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);

I got no result. How is the two things different ?

1 Answer 1

2

The grid filters in the admin panel use partial matching, they show a list of results that contain the text you entered.

loadByAttribute() uses exact matching to return one product with exactly the SKU that you entered. So you have to include the leading zeroes, which is by the way nothing that Magento adds automatically. It has to come from an extension or customization.

1
  • In fact, the products were imported using Magmi, but i don't know why it would add the zeros ...
    – mockingbid
    Commented Jun 13, 2016 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.