I have a custom import routine that creates configurable products and assigns children to them. These appear on the front end without issue until I manually run the stock status re-index.

I've done a snapshot from before and after the re-index and there is one table changing which is cataloginventory_stock_status where the stock_status column is changed from 1 (when it does appear) to 0 (now not appearing) for my configurable parent.

Can anyone explain this behaviour or know how to fix it?

Just to clarify, re-syncing my product which calls the following code:

$stockStatus = Mage::getModel('cataloginventory/stock_status');
$stockStatus->saveProductStatus($product->getId(), 1);

makes the options appear again until the next status re-index.


I have run into this problem when importing stock status via the API method. What I had to do was patch the core by rewriting a core module. Mage_Catalog_Model_Resource_Product_Status::getProductStatus() has a bug in it which incorrectly loads up the child statuses. In order to fix this bug, I replaced the $select assignment in the else statement of this method with

    $select = $adapter->select()
        array('t1' => $attributeTable),
        array('t2' => $attributeTable),
                    't1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id = ' . (int)$storeId,
        ->columns(array('value' => $valueCheckSql))
        ->where('t1.store_id = ?', Mage_Core_Model_App::ADMIN_STORE_ID)
        ->where('t1.attribute_id = ?', $attribute->getAttributeId())
        ->where('t1.entity_id IN(?)', $productIds);

Make sure that you do this by overriding the Mage_Catalog_Model_Resource_Product_Status::getProductStatus() method to accomplish this so that you are not modifying the core directly.

  • I tried this (I've put it in the core file for now to ensure it works) but it hasn't solved the issue unfortunately. Upon debugging, this method doesn't appear to be called. – webnoob Sep 4 '14 at 5:49

It turns out when importing the configurable parent I was skipping some code that put an entry into cataloginventory_stock_item which caused the stock_status to be set to 0 when the re-index process was run. With that in mind, we need to make sure a configurable parent has an item i.e:

$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->setData('stock_id', 1);
$stockItem->setData('qty', $stockLevel);
$stockItem->setData('use_config_min_qty', 1);
$stockItem->setData('use_config_backorders', 1);
$stockItem->setData('min_sale_qty', 1);
$stockItem->setData('use_config_min_sale_qty', 1);
$stockItem->setData('use_config_max_sale_qty', 1);
$stockItem->setData('is_in_stock', ($isInStock) ? 1 : 0);
$stockItem->setData('use_config_notify_stock_qty', 1);
$stockItem->setData('use_config_manage_stock', 0);
$stockItem->setData('manage_stock', ($this->getPropS($kcStockItem, 'STOCK_CONTROLLED') == '-1') ? 1 : 0); 
$stockItem->setData('backorders', $backorderVal);
$stockItem->setData('use_config_backorders', "0");

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.