cancel
Showing results for 
Search instead for 
Did you mean: 

Undefined index: websites

SOLVED

Undefined index: websites

Hi,

 

I've been getting this error:

"Undefined index: websites in \vendor\magento\module-catalog\Ui\Component\Listing\Columns\Websites.php on line 83"

 

before I got the error what I did is. I copied the file ProductDataProvider for me to override,

then when I go to Admin>Catalog>Product I am getting the error stated above.

 

 public function prepareDataSource(array $dataSource)
    {
        $websiteNames = [];
        foreach ($this->getData('options') as $website) {
            $websiteNames[$website->getWebsiteId()] = $website->getName();
        }      
        if (isset($dataSource['data']['items'])) {
            $fieldName = $this->getData('name');
            foreach ($dataSource['data']['items'] as & $item) {
                $websites = [];
                foreach ($item[$fieldName] as $websiteId) {
                    if (!isset($websiteNames[$websiteId])) {
                        continue;
                    }
                    $websites[] = $websiteNames[$websiteId];
                }
                $item[$fieldName] = implode(', ', $websites);
            }
        }

        return $dataSource;
    }
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Undefined index: websites

@gerald_cruz1  
Can you just revert what you did and check that the error still exist or not if not that means you did some wrong in the customization.
If that help you accept as solution.

View solution in original post

1 REPLY 1

Re: Undefined index: websites

@gerald_cruz1  
Can you just revert what you did and check that the error still exist or not if not that means you did some wrong in the customization.
If that help you accept as solution.