Skip to main content
edited title
Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

How to check if a collectionscollection has items?

Changed title
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

What does How to check if a product that is not found return in terms of Objectcollections has items?

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')
    ->load($mProduct)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    // ->getSelect()->limit(1);
    ->addFieldToFilter(array(
        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

gettype($man_collection)

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"

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')
    ->load($mProduct)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    // ->getSelect()->limit(1);
    ->addFieldToFilter(array(
        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

gettype($man_collection)

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"

How to check if a collections has items?

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')
    ->load($mProduct)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    // ->getSelect()->limit(1);
    ->addFieldToFilter(array(
        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

gettype($man_collection)

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"

deleted 251 characters in body; edited tags
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

I'm loading a product like the following:

               $man_collection = Mage::getModel('catalog/category')
                                 ->load($mProduct)
                                 ->getProductCollection()
                                 ->addAttributeToSelect('*')
                                 ->addAttributeToFilter('status', 1)
                                 ->addAttributeToFilter('visibility', 4)
                                        // ->getSelect()->limit(1);
                           ->addFieldToFilter(array(
                                            array('attribute' => 'color', 'eq'=>'1049''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

gettype($man_collection)

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"

I'm loading a product like the following:

               $man_collection = Mage::getModel('catalog/category')
                                 ->load($mProduct)
                                 ->getProductCollection()
                                 ->addAttributeToSelect('*')
                                 ->addAttributeToFilter('status', 1)
                                 ->addAttributeToFilter('visibility', 4)
                                        // ->getSelect()->limit(1);
                           ->addFieldToFilter(array(
                                            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

gettype($man_collection)

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"

I'm loading a product like the following:

$man_collection = Mage::getModel('catalog/category')
    ->load($mProduct)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4)
    // ->getSelect()->limit(1);
    ->addFieldToFilter(array(
        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

gettype($man_collection)

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"

Source Link
Stefanos
  • 231
  • 3
  • 13
Loading