1
votes

Hey guys i got a little dilema. I am running Magento ver. 1.7.0.2

When you create a configurable product you must set the stock "in stock" and then you add the other additional products with different stock.

When the additional products stock goes to 0 the main configurable product still is "in stock".

I want that when all the additional products stock goes to 0 then the main configurable product stock to turn into "out of stock".

I am using this custom code for "out of stock" products to appear always at the bottom page. And unless the configurable product dont receive the option "out of stock" it cant go to bottom page.

$this->getSelect()->joinLeft(array('_inventory_table'=>$this->getTable('cataloginventory/stock_item')),"_inventory_table.product_id = e.entity_id",array('is_in_stock', 'manage_stock'));
$this->addExpressionAttributeToSelect('on_top','(CASE WHEN (((_inventory_table.use_config_manage_stock = 1) AND (_inventory_table.is_in_stock = 1)) OR  ((_inventory_table.use_config_manage_stock = 0) AND (1 - _inventory_table.manage_stock + _inventory_table.is_in_stock >= 1))) THEN 1 ELSE 0 END)',array());
$this->getSelect()->order('on_top DESC');
3
Were you able to fix this? i'm facing the same issue herePablo S G Pacheco
hey i don't really remember what i did with that ... but i have a fix noted in a document that is related to this out of stock products. I just posted the answer ... take a look.Alex

3 Answers

0
votes

Have you made sure you have the correct Magento settings?

Inventory "Show Out Of Stock" = "No"
Configurable product Manage Stock = "No"
Simple product /Manage Stock = "Yes"
0
votes

I don't know if this would work for you but I think you can solve this from the template itself on the file "app/base/default/template/catalog/product/view.phtml", the line of code that says:

<?php if ($_product->isSaleable() && $this->hasOptions()):?>
    <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<? else : ?>
enter code here
<?php endif ?>

if you base it from the original file in the base template you may see this code starting from line 100 as you can see if all the options of the configurable product is empty it means that all products are already sold out causing it not to display the form fields necessary for adding it to the cart.

I hope this helps. :)

-1
votes

Add this code

$this->getSelect()->joinLeft(
                array('_inventory_table'=>$this->getTable('cataloginventory/stock_item')),
                "_inventory_table.product_id = e.entity_id",
                array('is_in_stock', 'manage_stock')
            );
            $this->addExpressionAttributeToSelect('on_top',
            '(CASE WHEN (((_inventory_table.use_config_manage_stock = 1) AND (_inventory_table.is_in_stock = 1)) OR  ((_inventory_table.use_config_manage_stock = 0) AND (1 - _inventory_table.manage_stock + _inventory_table.is_in_stock >= 1))) THEN 1 ELSE 0 END)',
             array());
            $this->getSelect()->order('on_top DESC');

before line:

if ($attribute == 'price' && $storeId != 0) {

in files:

app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php or in app/code/core/Mage/Catalog/Model/Product/Collection.php if you have Magento 1.7.0.0 +