Magento: the difference between downloading a product through a collection than a product model

So, we tried to download the product through a collection with certain criteria, we did not have sku or id, so when we did the following

 $prodModel->getCollection()
        ->addAttributeToFilter('visibility', $visibility)
        ->addAttributeToSelect('*')
        ->addCategoryFilter($cat)
        ->addAttributeToFilter('attribute_1', $sattribute_1)
        ->addAttributeToFilter('attribute_2', $attribute_2)
        ->addAttributeToFilter('type_id', 'configurable')
        ->load()
        ->getFirstItem()

At the same time, we got the desired product, but for some reason it did not have all the attributes, although we specified "*" for all the attributes. In particular, we did not receive the attribute of the media gallery. What we finished is to say that getFirstItem () -> getId () then downloaded the product and it found a job.

I just don’t understand that the whey loading the product with the catalog model will have more attributes.

+3
source share
1 answer

, , , , . URL .

(string)Mage::helper('catalog/image')->init($product, 'media_gallery');

__toString, . , , .. .

+1

Source: https://habr.com/ru/post/1768483/


All Articles