0

When in categroy admin, products tab don't show their status in any way. How to add that kind of feature? What files should I edit?

I think solution could be either:

  1. Add status field to listing header
  2. Add tag like "[Disabled]" to the product name in listing.

2 Answers 2

0

You need to extend the Category Product Grid block.
For this create a new module. Let's call it Easylife_Catalog.
You need the following files. app/etc/modules/Easylife_Catalog.xml - the declaration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Catalog>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Catalog />
                <Mage_Adminhtml />
            </depends>
        </Easylife_Catalog>
    </modules>
</config>

app/code/local/Easylife/Catalog/etc/config.xml - the configuration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Catalog>
            <version>0.0.1</version>
        </Easylife_Catalog>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <catalog_category_tab_product>Easylife_Catalog_Block_Adminhtml_Category_Tab_Product</catalog_category_tab_product>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

app/code/local/Easylife/Catalog/Block/Adminhtml/Category/Tab/Product.php - your new block

<?php
class Easylife_Catalog_Block_Adminhtml_Category_Tab_Product
    extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product {
    public function _preparePage() {
        $this->getCollection()->joinAttribute(
            'status',
            'catalog_product/status',
            'entity_id',
            null,
            'inner',
            $this->_getStore()->getId()
        );
        return parent::_preparePage();
    }
    public function _prepareColumns(){
        $this->addColumnAfter('status', array(
            'header'    => Mage::helper('catalog')->__('Status'),
            'index' => 'status',
            'type'  => 'options',
            'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
        ), 'sku');
        return parent::_prepareColumns();
    }
    protected function _getStore()
    {
        $storeId = (int) $this->getRequest()->getParam('store', 0);
        return Mage::app()->getStore($storeId);
    }
}

Clear the cache and give it a go.

0
0

For that you have to create the Custom category attribute.

1) The atwix provide you steps how to create the Category attribute via code.

2) The Extension is also available in Magento Connect.

Hope you got your answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.