0

When going to edit a configurable product, it would be nice to see the status (enabled/disabled) of each of the simple products when going to Associated products tab. I'm not using the stock options but instead managing products by their status manually so this is the only way to see if the associated products are in use or not. Any idea how to achieve this?

I found out one way it could be done is by adding something like the following in /app/core/code/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php

        $this->addColumn('status', array(
        'header'    => Mage::helper('catalog')->__('Status'),
        'renderer'  => 'adminhtml/catalog_product_edit_tab_super_config_grid_renderer_status',
        'filter'    => 'adminhtml/catalog_product_edit_tab_super_config_grid_filter_status',
        'index'     => 'status'
    ));

The above code snippet is a copy of the way in which the SKU is added to the grid. My problem is I cannot find where e.g. "adminhtml/catalog_product_edit_tab_super_config_grid_renderer_sku" or "adminhtml/catalog_product_edit_tab_super_config_grid_sku" are defined so I could clone the functionality.

Any tips where to look would be welcome...might not be a good idea to edit the core files anyways so tip of how to do this with an extension would be appreciated :)

0

Firstly you should not make any edit to core

Take a look at Add custom renderer for a custom column in Magento grid

renderer - will display the content in the grid filter - Will all you to search that column in the grid

However I dont think using renderer is the way to go here.

There are other methods to accomplish this but one of the quickest is to rewrite Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid (see how to rewrite grid)

class <Module>_<Company>_Block_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Prepare collection
     *
     * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
     */
    protected function _prepareCollection()
    {
        $allowProductTypes = array();
        foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
            $allowProductTypes[] = $type->getName();
        }

        $product = $this->_getProduct();
        $collection = $product->getCollection()
            ....
            ->addAttributeToSelect('status')
            ....
            ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');

        ...
    }


    protected function _prepareColumns()
    {
        $product = $this->_getProduct();
        $attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);

        ...

         $this->addColumn('status', array(
            //'filter_index' => 'status',
            'header' => Mage::helper('sales')->__('Status'),
            'index' => 'status',
            'type'  => 'options',
            'width' => '70px',
            'filter_index' => 'status',
            'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
        ));
...
}
  • Hi, thanks for the tip; however just a tiny question, what should I be using for getting the options? The lines in your example are for sales, i'm looking for the product status :) – user2166737 Nov 5 '14 at 23:03
  • Hmm, found out the correct one for getting the options, it is Mage::getSingleton('catalog/product_status')->getOptionArray() However still facing an issue that by default, the Status for each of the rows shows as empty but when I use the search, they get returned correctly. Any ideas what is causing that behavior? I've got all the join attributes added like in the example and tried indexing + cache clear but not help – user2166737 Nov 5 '14 at 23:22
  • Never mind, got it sorted; had a typo in ->joinAttribute('name', 'catalog_product/status', 'entity_id', null, 'inner') – user2166737 Nov 5 '14 at 23:36
  • Did you get it to work? – Renon Stewart Nov 5 '14 at 23:41
  • Yes got it working, thanks :) Marking as accepted. – user2166737 Nov 6 '14 at 0:06
0

Essentially you're defining a rendering block. So ideally, with an extension, you would first extend (and rewrite) the Admin Grid you noted there, and then setup a renderer within your module for the added status column.

You would then be able to define the output in the renderer similarly to the Inventory renderer (adminhtml/catalog_product_edit_tab_super_config_grid_renderer_inventory), which represents the block Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Renderer_Inventory.

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.