Tweeted twitter.com/StackMagento/status/1059052826276577282
3 fixed grammer
source | link

I am working on custom extension and need to overideoverride Magento\Catalog\Block\Product\View\Gallery block.

I amhave followed this method.

In di.xml,

<preference for="Magento\Catalog\Block\Product\View\Gallery" type="[Company]\[Vendor]\Block\Catalog\Product\View\Gallery"/>

In [Company][Vendor]\Block\Catalog\Product\View\Gallery.php

namespace [Company]\[Vendor]\Block\Catalog\Product\View;

class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{

public function getGalleryImagesJson()
   {

        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {
            $imagesItems[] = [
                'thumb' => $image->getData('small_image_url'),
                'img' => $image->getData('medium_image_url'),
                'full' => $image->getData('large_image_url'),
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
     return json_encode($imagesItems);
    }
}

When I do this, More Views Images of the product is don't show any more.

Can you help me into this.?

Thanks in advance.

I am working on custom extension and need to overide Magento\Catalog\Block\Product\View\Gallery block.

I am followed this method.

In di.xml,

<preference for="Magento\Catalog\Block\Product\View\Gallery" type="[Company]\[Vendor]\Block\Catalog\Product\View\Gallery"/>

In [Company][Vendor]\Block\Catalog\Product\View\Gallery.php

namespace [Company]\[Vendor]\Block\Catalog\Product\View;

class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{

public function getGalleryImagesJson()
   {

        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {
            $imagesItems[] = [
                'thumb' => $image->getData('small_image_url'),
                'img' => $image->getData('medium_image_url'),
                'full' => $image->getData('large_image_url'),
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
     return json_encode($imagesItems);
    }
}

When I do this, More Views Images of product is don't show any more.

Can you help me into this.

Thanks in advance.

I am working on custom extension and need to override Magento\Catalog\Block\Product\View\Gallery block.

I have followed this method.

In di.xml,

<preference for="Magento\Catalog\Block\Product\View\Gallery" type="[Company]\[Vendor]\Block\Catalog\Product\View\Gallery"/>

In [Company][Vendor]\Block\Catalog\Product\View\Gallery.php

namespace [Company]\[Vendor]\Block\Catalog\Product\View;

class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{

public function getGalleryImagesJson()
   {

        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {
            $imagesItems[] = [
                'thumb' => $image->getData('small_image_url'),
                'img' => $image->getData('medium_image_url'),
                'full' => $image->getData('large_image_url'),
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
     return json_encode($imagesItems);
    }
}

When I do this, More Views Images of the product is don't show any more.

Can you help me into this?

Thanks in advance.

2 added 1764 characters in body
source | link

I am working on custom extension and need to overide Magento\Catalog\Block\Product\View\Gallery block.

How canI am followed this method.

In di.xml,

<preference for="Magento\Catalog\Block\Product\View\Gallery" type="[Company]\[Vendor]\Block\Catalog\Product\View\Gallery"/>

In [Company][Vendor]\Block\Catalog\Product\View\Gallery.php

namespace [Company]\[Vendor]\Block\Catalog\Product\View;

class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{

public function getGalleryImagesJson()
   {

        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {
            $imagesItems[] = [
                'thumb' => $image->getData('small_image_url'),
                'img' => $image->getData('medium_image_url'),
                'full' => $image->getData('large_image_url'),
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
     return json_encode($imagesItems);
    }
}

When I do this? Any one have example, please provideMore Views Images of product is don't show any more.

Can you help me into this.

Thanks in advance.

I am working on custom extension and need to overide Magento\Catalog\Block\Product\View\Gallery block.

How can I do this? Any one have example, please provide.

Thanks in advance.

I am working on custom extension and need to overide Magento\Catalog\Block\Product\View\Gallery block.

I am followed this method.

In di.xml,

<preference for="Magento\Catalog\Block\Product\View\Gallery" type="[Company]\[Vendor]\Block\Catalog\Product\View\Gallery"/>

In [Company][Vendor]\Block\Catalog\Product\View\Gallery.php

namespace [Company]\[Vendor]\Block\Catalog\Product\View;

class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{

public function getGalleryImagesJson()
   {

        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {
            $imagesItems[] = [
                'thumb' => $image->getData('small_image_url'),
                'img' => $image->getData('medium_image_url'),
                'full' => $image->getData('large_image_url'),
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
     return json_encode($imagesItems);
    }
}

When I do this, More Views Images of product is don't show any more.

Can you help me into this.

Thanks in advance.

1
source | link

Magento 2 : Overide Magento\Catalog\Block\Product\View\Gallery Block

I am working on custom extension and need to overide Magento\Catalog\Block\Product\View\Gallery block.

How can I do this? Any one have example, please provide.

Thanks in advance.