magento-2-product-slider
magento-2-product-slider copied to clipboard
Most Viewed block showing disabled products
Preconditions
Magento 2.3.6 (Community) PHP 7.2 MySQL 5.7
Steps to reproduce
- Create a 'Most Viewed' block
Expected result
- I would expect to see a slider of 'most viewed' active products
Actual result
- 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());
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!