0

I use custom variable in Mirasvit Extension for export parent images also from variants.

For test I export single product and working correct. Now I set filter with export all configurable products in website and I get issue:

Notice: Undefined variable: images in /home/azinvest/domains/under.pl/public_html/pub/media/feed/tmp/16110634559723.php on line 14

On line 14 custom variable is:

 }
    $images = implode(', ', $images);
}

Here is full code dynamic variable.

$storeManager = $objectManager->create('\Magento\Store\Model\StoreManagerInterface');
$mediaUrl = $storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
if ($product->getTypeId() != 'configurable') {
$images = $mediaUrl . 'catalog/product' . $product->getImage();
} else {
    $children = $product->getTypeInstance()->getUsedProducts($product);
    foreach ($children as $child){
        if ($child->getMediaGalleryImages()) {
            foreach ($child->getMediaGalleryImages() as $image) {
    $images[] = $mediaUrl . 'catalog/product' . $image['file'];
            }
        }
}
    $images = implode(', ', $images);
}
return  $images;

Any solution?

1
  • Define the $images variable blank above the if condition like this , $images = ' '; Jan 21, 2021 at 4:22

1 Answer 1

0

please define variable images before if the condition

Ex. $images = ' ';

2
  • Can you explain this further? Can you improve our code? Thanks!
    – Sylvester
    Jan 19, 2021 at 18:55
  • yes, please share full code
    – Himanshu
    Jan 20, 2021 at 9:24

Your Answer

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

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