Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Product.php
Go to the documentation of this file.
1 <?php
7 
11 class Product
12 {
20  public function afterGetMediaAttributes(\Magento\Catalog\Model\Product $product, $imageRoles)
21  {
22  if ($product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
23  && $product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
24  ) {
25  if (is_array($imageRoles)) {
26  unset($imageRoles[\Magento\Swatches\Model\Swatch::SWATCH_IMAGE_NAME]);
27  }
28  }
29 
30  return $imageRoles;
31  }
32 }
afterGetMediaAttributes(\Magento\Catalog\Model\Product $product, $imageRoles)
Definition: Product.php:20