Skip to main content
Add summary
Source Link
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422

The problem lies in the call to addStoreFilter() in getUsedProductCollection():

public function getUsedProductCollection($product = null)
{
    $collection = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
        ->setFlag('require_stock_items', true)
        ->setFlag('product_children', true)
        ->setProductFilter($this->getProduct($product));
    if (!is_null($this->getStoreFilter($product))) {
        $collection->addStoreFilter($this->getStoreFilter($product));
    }

    return $collection;
}

This adds filters to only show products that are salable in the current store.

If $configurable is the type instance of your configurable product, you can unset the store filter like this before calling getUsedProductCollection():

$configurable->setStoreFilter(null);

Complete solution:

$configurable = $product->getTypeInstance();

$configurable->setStoreFilter(null);
$simpleCollection = $configurable->getUsedProductCollection()
    ->addAttributeToSelect('*')
    ->addFilterByRequiredOptions();

foreach ($simpleCollection as $simple) {
   //$simple->getName();
}

The problem lies in the call to addStoreFilter() in getUsedProductCollection():

public function getUsedProductCollection($product = null)
{
    $collection = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
        ->setFlag('require_stock_items', true)
        ->setFlag('product_children', true)
        ->setProductFilter($this->getProduct($product));
    if (!is_null($this->getStoreFilter($product))) {
        $collection->addStoreFilter($this->getStoreFilter($product));
    }

    return $collection;
}

This adds filters to only show products that are salable in the current store.

If $configurable is the type instance of your configurable product, you can unset the store filter like this before calling getUsedProductCollection():

$configurable->setStoreFilter(null);

The problem lies in the call to addStoreFilter() in getUsedProductCollection():

public function getUsedProductCollection($product = null)
{
    $collection = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
        ->setFlag('require_stock_items', true)
        ->setFlag('product_children', true)
        ->setProductFilter($this->getProduct($product));
    if (!is_null($this->getStoreFilter($product))) {
        $collection->addStoreFilter($this->getStoreFilter($product));
    }

    return $collection;
}

This adds filters to only show products that are salable in the current store.

If $configurable is the type instance of your configurable product, you can unset the store filter like this before calling getUsedProductCollection():

$configurable->setStoreFilter(null);

Complete solution:

$configurable = $product->getTypeInstance();

$configurable->setStoreFilter(null);
$simpleCollection = $configurable->getUsedProductCollection()
    ->addAttributeToSelect('*')
    ->addFilterByRequiredOptions();

foreach ($simpleCollection as $simple) {
   //$simple->getName();
}
Source Link
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422

The problem lies in the call to addStoreFilter() in getUsedProductCollection():

public function getUsedProductCollection($product = null)
{
    $collection = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
        ->setFlag('require_stock_items', true)
        ->setFlag('product_children', true)
        ->setProductFilter($this->getProduct($product));
    if (!is_null($this->getStoreFilter($product))) {
        $collection->addStoreFilter($this->getStoreFilter($product));
    }

    return $collection;
}

This adds filters to only show products that are salable in the current store.

If $configurable is the type instance of your configurable product, you can unset the store filter like this before calling getUsedProductCollection():

$configurable->setStoreFilter(null);