magento-2-product-slider icon indicating copy to clipboard operation
magento-2-product-slider copied to clipboard

Most Viewed block showing disabled products

Open siliconalchemy opened this issue 4 years ago • 1 comments

Preconditions

Magento 2.3.6 (Community) PHP 7.2 MySQL 5.7

Steps to reproduce

  1. Create a 'Most Viewed' block

Expected result

  1. I would expect to see a slider of 'most viewed' active products

Actual result

  1. I see a slider of 'most viewed' products including disabled products

It looks like block code is missing visibility filter: https://github.com/mageplaza/magento-2-product-slider/blob/master/Block/MostViewedProducts.php

getProductCollection() method is:

        $collection = $this->_mostViewedProductsFactory->create()
            ->setStoreId($this->getStoreId())->addViewsCount()
            ->addStoreFilter($this->getStoreId())
            ->setPageSize($this->getProductsCount());

should probably be something like:

        $collection = $this->_mostViewedProductsFactory->create()
            ->setStoreId($this->getStoreId())->addViewsCount()
            ->addStoreFilter($this->getStoreId())
            ->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds())
            ->setPageSize($this->getProductsCount());

siliconalchemy avatar Oct 22 '20 10:10 siliconalchemy

First of all, thank you for contacting us. I am Elle from Mageplaza Support Team.

Support from amazing customers like you helps our business grow and evolve thanks to your valuable contribution. We will consider making it more readily available in the next versions.

That being said, if there’s anything else that we can help you with at the moment, please feel welcome to reach out, and we would be more than happy to help. Warmest wishes from all of us here at Mageplaza!

Hant186 avatar Oct 23 '20 04:10 Hant186