What does a product that is not found return in terms of Object?

I'm loading a product like the following:

$man_collection = Mage::getModel('catalog/category')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    // ->getSelect()->limit(1);
        array('attribute' => 'color', 'eq' => '1049')

Assuming that this specific product with this color code 1049 does not exist in the database, how can I validate it? If I try


it still returns Object. So is there a way to validate this? Like "if product with color code 1049 found proceed, else echo not found"


4 Answers 4


You can check the size of your collection:

if ($man_collection->getSize()) {
} else {
    echo "not found";

Explaination here: Difference between getSize() and count() on collection

Edit: tested for 750 products


  • Total Incl. Wall Time (microsec): 67,567 microsecs
  • Total Incl. CPU (microsecs): 67,599 microsecs
  • Total Incl. MemUse (bytes): 11,719,168 bytes
  • Total Incl. PeakMemUse (bytes): 11,648,152 bytes
  • Number of Function Calls: 1,047


  • Total Incl. Wall Time (microsec): 6,371 microsecs
  • Total Incl. CPU (microsecs): 4,402 microsecs
  • Total Incl. MemUse (bytes): 140,816 bytes
  • Total Incl. PeakMemUse (bytes): 96,000 bytes
  • Number of Function Calls: 191

$collection->count() or sizeof($collection)

  • Total Incl. Wall Time (microsec): 2,130,568 microsecs
  • Total Incl. CPU (microsecs): 2,080,617 microsecs
  • Total Incl. MemUse (bytes): 12,899,872 bytes
  • Total Incl. PeakMemUse (bytes): 13,002,256 bytes
  • Number of Function Calls: 101,073
  • Thank you!!! I wanted to see if the Object is empty in terms of data. If it's empty or not it will always return Object. But if it does not contain data the $collection->getData() is the function I was looking for.
    – Stefanos
    Commented Jun 21, 2017 at 9:20
  • Understand, but use getData()only on (collection) objects, but for collections itself you should go with getSize() :)
    – sv3n
    Commented Jun 21, 2017 at 10:03

To answer your question to why you still get the response as an object even if the collection does not contain any products...
A product collection is an object by itself. It contains a lot of things other than an array (not really an array) of products.
It contains references to the tables involved in the query, the query, db connection and a lot others.


You can try this-

   //products found
   // products not found

Got it.!

It is:


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.