What I want to achive is, to show one column in the catalog grid, which contains the stock status.

Here is my code for adding it to the collection that:

    $collection->joinTable( 'cataloginventory/stock_status','product_id=entity_id', array("stock_status" => "stock_status") )

I also add a new column:

            'header'=> 'Stock Status', 
            'width' => '60px',
            'index' => 'stock_status',
            'type'  => 'options',
            'options' => array('1'=>'In Stock','0'=>'Out Of Stock'),

The Problem now is that if no stock status is set, there is no entry in the db-table cataloginventory_stock_status. This also means, that products which have no stock status set will not even be displayed in this new catalog grid.

Is there a way to display them anyway?

  • instead, try using catalog_inventory_stock_item and test is_in_stock – Julien Lachal Jul 17 '14 at 7:35

That happens because, by default joinTable performs an INNER JOIN. You can pass an additional parameter to make a LEFT JOIN.

        array("stock_status" => "stock_status"),
        null ,
| improve this answer | |

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.