I'm having issues trying to create a collection of child / associated products given a particular parent / configurable product.

I have no issue creating the collection for the parent (i.e. configurable) products that I want, no issue getting my entity IDs for the child products (that is, in the below code snippet, $childIds contains the correct values) but when I attempt to build my collection, $childrenCollection->getSize() is sometimes different than count($childIds[0]), even though I'm filtering based on those values.



$attCodeBrand = 'brand';

$attBrand = Mage::getModel('catalog/product')->getResource()->getAttribute($attCodeBrand);

$brandId = $attBrand->getSource()->getOptionId('Sears');

$configurableCollection = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
        ->addAttributeToFilter('brand', array('eq'=>$brandId));

while ($parent = $configurableCollection->fetchItem())
        $parentId = $parent->getId();

        $childIds = Mage::getSingleton('catalog/product_type_configurable')->getChildrenIds($parentId);

        $childrenCollection = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToFilter('entity_id', array('in'=>$childIds[0]));

I thought perhaps that my associated products somehow linked to a product with a bad ID, but I have tested explicitly loading the products that are missed in $childrenCollection and there's no issue there.

Is there some sort of implicit filtering that's going on that I'm not aware of?

Edit: Magento version is EE.

1 Answer 1


I forgot to set the store ID.


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.