1
votes

We have an existing customization that appears to have broken when we upgraded from 1.7 to 1.9 community.

The customization adds a column to the associated products grid.

The customization is a local override of app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php

This was done before I started on the project

$this->addColumn('breakdown_part_no', array(
'header'    => Mage::helper('catalog')->__('Part No'),
'name'      => 'breakdown_part_no',
'type'      => 'varchar',
'index'     => 'breakdown_part_no',
'width'     => '120px',
'editable'  => true,
 ));

This was added to _prepareColumns()

Another customization was added to method getSelectedGroupedProducts()

public function getSelectedGroupedProducts()
{
    $associatedProducts = Mage::registry('current_product')->getTypeInstance(true)
    ->getAssociatedProducts(Mage::registry('current_product'));
    $products = array();
    foreach ($associatedProducts as $product) {
        $products[$product->getId()] = array(
            'qty'       => $product->getQty(),
            'position'  => $product->getPosition(),
            'breakdown_part_no' => $product->getBreakdownPartNo(),
        );
}
    return $products;
}

The behavior is that the column appears in the admin and can be edited, however when saved, it does not save any value.

If I modify the getSelectedGroupedProducts part and set a hard coded value, it displays still no value (blank field), but interestingly if I click save with no value, it saves the value that was hard coded. If I enter any value in the field, it saves as a blank. This is really strange behavior that makes no sense to me.

If I change one of the other fields, such as position to be a hard coded value, it appears instantly and works as expected. Please let me know the proper way for this to work.

1

1 Answers

0
votes

There are several posts on various forums about how to do the above and the modification mentioned is true, but what all of the other posts left out was the adminhtml layout input. When a user edits product data in Magento Admin (Associated Products), the data is serialized and sent to the controller save action. I noticed that the fields were not present when a value was entered. This is because the value wasn't in the layout so it was being stripped off of the request before it was posted to the controller.

Add input field in adminhtml/default/default/layout/catalog.xml adminhtml_catalog_product_supergroup addColumnInputName