1

I'm trying to replicate the functionality of the grouped-product module and can't seem to understand how it displays the linked attribute position. When adding my own linked product attribute which has data associated to the associated products I only see empty values. However, if I echo out $linkItem->getExtensionAttributes()->getMytestattribute() in the fillData() function I see the values on my screen.

Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\Grouped

I see this:

protected function fillData(ProductInterface $linkedProduct, ProductLinkInterface $linkItem)
{
    ....
    return [
        ....
        'position' => $linkItem->getPosition(),
        ....
    ];
}

And this:

/**
 * Fill meta columns
 *
 * @return array
 */
protected function fillMeta()
{
    return [
        ....
        'position' => [
            'arguments' => [
                'data' => [
                    'config' => [
                        'dataType' => Form\Element\DataType\Number::NAME,
                        'formElement' => Form\Element\Input::NAME,
                        'componentType' => Form\Field::NAME,
                        'dataScope' => 'position',
                        'sortOrder' => 100,
                        'visible' => false, //change to true and it shows this field with the assigned values for position
                    ],
                ],
            ],
        ],
    ];
}

However, I don't see position inside of \view\adminhtml\ui_component\grouped_product_listing.xml. I want to achieve the same thing by adding a linked product attribute to a new column for the associated products grid and not the popup where you add more products to the grid.

What am I missing here??

Update: I figured out you can add 'value' => 'My data should populate here' to the fillMeta function for the new column but not sure how to pass data to that field or even if this is the correct way to pass data to this new column?

Example:

    'mytestattribute' => [
        'arguments' => [
            'data' => [
                'config' => [
                    'dataType' => Form\Element\DataType\Number::NAME,
                    'formElement' => Form\Element\Input::NAME,
                    'componentType' => Form\Field::NAME,
                    'dataScope' => 'mytestattribute',
                    'label' => __('My Test Attribute'),
                    'fit' => true,
                    'sortOrder' => 85,
                    'value' => 'My data should populate here',
                    'validation' => [
                        'validate-number' => true,
                    ],
                ],
            ],
        ],
    ],
  • Hi, I can't even get the echo to work on my new attribute, how did you get that far? Thanks – William Oakley Jan 9 '17 at 13:19
0

I really hate to answer my own questions but since this took a long time to debug I thought I would save others from hours of the same headaches I faced.

It appears that the sortOrder in the Modifier Pool is very important. Although I know it loads the specified files in a certain order based on the value you set I'm still not sure what file or how it was removing my data from the column based on the lower value.

Originally I had the sortOrder set to 72 if I remember right but after changing that value to 130 my missing column data appeared.

\Vendor\Module\etc\adminhtml\di.xml

<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
    <arguments>
        <argument name="modifiers" xsi:type="array">
            <item name="package" xsi:type="array">
                <item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Product\Form\Modifier\Package</item>
                <item name="sortOrder" xsi:type="number">130</item>
            </item>
        </argument>
    </arguments>
</virtualType>
| improve this answer | |

Your Answer

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

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