3

What is different between getCollection(); and $product->getData();

$products_collection = Mage::getModel('catalog/product')
**getCollection();
->addAttributeToSelect('*')
->addFieldToFilter('price','5.00'); 

and

$product->getData(); 
5

As the name suggest - getCollection() returns a collection/list of many products by some criteria (addFieldToFilter()). getData() returns full data for specific product.

2

getCollection() return the collection/list of products based on the filter given.

While in getData() its return the products data in an array based on the filter used on collection.

There is also one other method called getItems() it returns products object list.

getData() returns product data as an array while getItems() returns products objectlist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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