Question

We are creating grouped products based around images of engine and part schematics. Those schematics have number markers for each specific piece of the schematic and we're able to match the position of the associated product to the number marker in the schematic.

Our problem is that some schematics have the same part in multiple positions. An example, the same washer may show up in position 1, 15, and 40. The associated product grid only allows us to indicate one position for that washer.

Any ideas on how we could configure a grouped product to allow for multiple positions of an associated product? I've been digging for several hours now trying to find a way to add an additional attribute to an associated product but I'm not finding any possibilities there.

Was it helpful?

Solution

After more hours searching online I was able to work out a solution based on a post in another magento forum. I'm going to rewrite it here in hopes that it helps someone else who stumbles in.

For this approach I decided to add a custom column in the associated product grid for my grouped product. To add the new column I copied the file in: app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php into my local code at: app/code/localMage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php

In function _prepareColumns()` I added this:

    $this->addColumn('diagrampos', array(
      'header'    => Mage::helper('catalog')->__('Other Position'),
      'name'      => 'diagrampos',
      'index'     => 'diagrampos',
      'width'     => '60px',
      'editable'  => true
    ));

Further down in that file we need to change the getSelectedGroupedProducts() at line 214 so that our updates in the admin will be saved correctly. Here's how that should look now:

    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(),
              'diagrampos'  => $product->getDiagrampos()
            );
        }
        return $products;
    }

Then we need to update the database table for catalog_product_link_attribute. I added the following values as a new row to the table. You may need to adjust the first value depending on the current increment in your table:

product_link_attribute_id   => 6
link_type_id                => 3
product_link_attribute_code => diagrampos
data_type                   => varchar

Next we need to change app/design/adminhtml/default/default/layout/catalog.xml so that the serializer picks up on our new field. We need to modify the layout under the node <adminhtml_catalog_product_supergroup> by adding a new line under addColumnInputName so that it looks like:

    <action method="addColumnInputName">
        <input_name>qty</input_name>
        <input_name>position</input_name>
        <input_name>diagrampos</input_name>
    </action>

I'm now able to add a comma separated list of integers in that input field. With moderate customization to the grouped product templates I can now display the same associated product SKU in multiple positions.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top