I created a product custom attribute

            'is_visible_in_grid' => true,
            'is_html_allowed_on_front' => false,
            'visible_on_front' => false,
            'visible' => true,
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'label' => __('Subscription'),
            'source' => \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class,
            'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\Boolean::class,
            'type' => 'int',
            'is_used_in_grid' => true,
            'required' => false,
            'input' => 'boolean',
            'is_filterable_in_grid' => true,
            'sort_order' => 10,
            'group' => 'Subscription',

It's properly created everywhere...now I want to add a modifier on that grid for this attribute.

To do so i'm creating

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <columns name="product_columns">
        <column name="is_subscription_product" class="Vendor\Subscription\Model\Product\Attribute\Renderer\IsSubscription">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>

And in the renderer class i'm doing something like that

public function prepareDataSource(array $dataSource)
    if (isset($dataSource['data']['items'])) {
        foreach ($dataSource['data']['items'] as &$item) {
            if($this->getData('name') == 'is_subscription_product') {

But then I'm hitting the error

Notice: Undefined index: is_subscription_product

I don't get why the data is not in the $item object....cause if I remove the modifier the data is rendered in grid...so it should be there...what am I missing ?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.