0

I have a custom field that I would like to add to all areas in the admin panel where you can change the quantity of a product. I currently am of the impression that I have to rewrite each template individually.

For example, to add the field to the inventory tab in edit product I did a rewrite of the template like so:

Config.xml

<adminhtml>
    <rewrite>
        <catalog_product_edit_tab_inventory>
          Vish_StockMovements_Block_Adminhtml_Catalog_Product_Edit_Tab_Inventory
        </catalog_product_edit_tab_inventory>
    </rewrite>  
</adminhtml> 

Inventory.php

<?php
class Vish_StockMovements_Block_Adminhtml_Catalog_Product_Edit_Tab_Inventory extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory
{

     public function getStockReasons(){

         $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'stock_reason');

         if ($attribute->usesSource()) {
            $options = $attribute->getSource()->getAllOptions(true);
        }

     return $options; 
     } 
 public function __construct()
    {
        parent:: __construct();
        $this->setTemplate('vish/catalog/product/tab/inventory.phtml');
    }
}

I believe then I would accordingly do the same for the update attributes action. This seems redundant and repetitive, and was wanting to ask if I am doing this correctly? or does magento have a better way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.