From 0fbb020d44d68d79b168de6ef0fb131e3d58a87a Mon Sep 17 00:00:00 2001 From: Emipro Date: Tue, 17 Jul 2018 12:17:18 +0530 Subject: [PATCH 1/3] solution for Magento 2.2.5: Configurable Product with Only Size Options (No Color Options) Shows No Image in Cart --- .../Catalog/Block/Product/ImageBuilder.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ImageBuilder.php b/app/code/Magento/Catalog/Block/Product/ImageBuilder.php index ad62031976ee1..c10151b10612f 100644 --- a/app/code/Magento/Catalog/Block/Product/ImageBuilder.php +++ b/app/code/Magento/Catalog/Block/Product/ImageBuilder.php @@ -121,21 +121,13 @@ protected function getRatio(\Magento\Catalog\Helper\Image $helper) */ public function create() { - /** @var \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface $simpleOption */ - $simpleOption = $this->product->getCustomOption('simple_product'); - - if ($simpleOption !== null) { - $optionProduct = $simpleOption->getProduct(); - $this->setProduct($optionProduct); - } - /** @var \Magento\Catalog\Helper\Image $helper */ $helper = $this->helperFactory->create() ->init($this->product, $this->imageId); $template = $helper->getFrame() - ? 'Magento_Catalog::product/image.phtml' - : 'Magento_Catalog::product/image_with_borders.phtml'; + ? 'Magento_Catalog::product/image.phtml' + : 'Magento_Catalog::product/image_with_borders.phtml'; try { $imagesize = $helper->getResizedImageInfo(); @@ -150,11 +142,11 @@ public function create() 'width' => $helper->getWidth(), 'height' => $helper->getHeight(), 'label' => $helper->getLabel(), - 'ratio' => $this->getRatio($helper), + 'ratio' => $this->getRatio($helper), 'custom_attributes' => $this->getCustomAttributes(), 'resized_image_width' => $imagesize[0], 'resized_image_height' => $imagesize[1], - 'product_id' => $this->product->getId() + 'product_id' => $this->product->getId(), ], ]; From 054f23921b98cd34cfa7679ce070f9066fc930a1 Mon Sep 17 00:00:00 2001 From: Emipro Date: Sat, 4 Aug 2018 11:09:58 +0530 Subject: [PATCH 2/3] Solution for User role issue with customer group --- app/code/Magento/Customer/etc/acl.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Customer/etc/acl.xml b/app/code/Magento/Customer/etc/acl.xml index a500608e1cdf5..8c3151a2e0acc 100644 --- a/app/code/Magento/Customer/etc/acl.xml +++ b/app/code/Magento/Customer/etc/acl.xml @@ -12,6 +12,7 @@ + @@ -19,10 +20,7 @@ - - - - + From d0b1a6ea276225cdff7372fde0eb9dce28c0252e Mon Sep 17 00:00:00 2001 From: Emipro Technologies Pvt Ltd Date: Sat, 4 Aug 2018 11:17:09 +0530 Subject: [PATCH 3/3] This file is changed for other issue This file is changed for other issue's solution but by mistake it is displaying in this pull request. --- .../Catalog/Block/Product/ImageBuilder.php | 155 ------------------ 1 file changed, 155 deletions(-) delete mode 100644 app/code/Magento/Catalog/Block/Product/ImageBuilder.php diff --git a/app/code/Magento/Catalog/Block/Product/ImageBuilder.php b/app/code/Magento/Catalog/Block/Product/ImageBuilder.php deleted file mode 100644 index c10151b10612f..0000000000000 --- a/app/code/Magento/Catalog/Block/Product/ImageBuilder.php +++ /dev/null @@ -1,155 +0,0 @@ -helperFactory = $helperFactory; - $this->imageFactory = $imageFactory; - } - - /** - * Set product - * - * @param Product $product - * @return $this - */ - public function setProduct(Product $product) - { - $this->product = $product; - return $this; - } - - /** - * Set image ID - * - * @param string $imageId - * @return $this - */ - public function setImageId($imageId) - { - $this->imageId = $imageId; - return $this; - } - - /** - * Set custom attributes - * - * @param array $attributes - * @return $this - */ - public function setAttributes(array $attributes) - { - $this->attributes = $attributes; - return $this; - } - - /** - * Retrieve image custom attributes for HTML element - * - * @return string - */ - protected function getCustomAttributes() - { - $result = []; - foreach ($this->attributes as $name => $value) { - $result[] = $name . '="' . $value . '"'; - } - return !empty($result) ? implode(' ', $result) : ''; - } - - /** - * Calculate image ratio - * - * @param \Magento\Catalog\Helper\Image $helper - * @return float|int - */ - protected function getRatio(\Magento\Catalog\Helper\Image $helper) - { - $width = $helper->getWidth(); - $height = $helper->getHeight(); - if ($width && $height) { - return $height / $width; - } - return 1; - } - - /** - * Create image block - * - * @return \Magento\Catalog\Block\Product\Image - */ - public function create() - { - /** @var \Magento\Catalog\Helper\Image $helper */ - $helper = $this->helperFactory->create() - ->init($this->product, $this->imageId); - - $template = $helper->getFrame() - ? 'Magento_Catalog::product/image.phtml' - : 'Magento_Catalog::product/image_with_borders.phtml'; - - try { - $imagesize = $helper->getResizedImageInfo(); - } catch (NotLoadInfoImageException $exception) { - $imagesize = [$helper->getWidth(), $helper->getHeight()]; - } - - $data = [ - 'data' => [ - 'template' => $template, - 'image_url' => $helper->getUrl(), - 'width' => $helper->getWidth(), - 'height' => $helper->getHeight(), - 'label' => $helper->getLabel(), - 'ratio' => $this->getRatio($helper), - 'custom_attributes' => $this->getCustomAttributes(), - 'resized_image_width' => $imagesize[0], - 'resized_image_height' => $imagesize[1], - 'product_id' => $this->product->getId(), - ], - ]; - - return $this->imageFactory->create($data); - } -}