mage-enhanced-admin-grids icon indicating copy to clipboard operation
mage-enhanced-admin-grids copied to clipboard

Edit Group Price?

Open rmvdev opened this issue 8 years ago • 0 comments

I wanted to add the group price of a specific customer group to my grid, which I did using the code below;

My grid override -

protected function _prepareColumns()
    {
        $store = $this->_getStore();
        $this->addColumnAfter('value',
            array(
                'header'=> Mage::helper('catalog')->__('Group Price'),
                'column_css_class'=>'a-right',
                'type'  => 'price',
                'currency_code' => $store->getBaseCurrency()->getCode(),
                'index' => 'entity_id',
               'renderer'  => 'MyCompany_CatalogGrid_Block_Adminhtml_Catalog_Product_Groupprice', 
            ),
            'price'
         );

        return parent::_prepareColumns();
    }
}

My renderer -

    public function render(Varien_Object $row)
    {
        $product_id =  $row->getData($this->getColumn()->getIndex());
        $loadproduct = Mage::getModel('catalog/product')->load($product_id);
        $final_group_price =  '';
        $group_prices = $loadproduct->getData('group_price');
        $formatted_group_price = '';
        foreach ($group_prices as $group_price)
        {
            if($group_price['cust_group']=="2")
            {
                    $final_group_price =   $group_price['price'];
                    $formatted_group_price = Mage::helper('core')->currency($final_group_price, true, false);
                    break;
            }
        }
        return $formatted_group_price;

    }

}

It displays the group price perfectly but I can't see to make it editable from the grid - I added the following to the _getEditableFields function and it makes the cell editable but doesn't save the changes;

        'value' => array(
            'type'            => 'text',
            'required'        => false,
            'render_reload'   => false,
            'form_class'      => 'validate-number',
            'edit_block_type' => 'customgrid/widget_grid_form_static_product_inventory',
            'inventory_field' => 'entity_id',
        ),

This makes the cell editable but once the data is entered and submitted the group price isn't updated

Any help would be appreciated

rmvdev avatar Aug 14 '17 22:08 rmvdev