Get Product collection using custom attributes of Best Seller
<?php
use Magento\Framework\App\Action\Action;
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$productCollection = $_objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$collection = $productCollection->create()->addAttributeToSelect('*')->addAttributeToFilter('home_best_seller', '1')->setPageSize(10)->setOrder('sort_order', 'DESC')->load();
$imagewidth = 400;
$imageheight = 400;
$imageHelper = $_objectManager->get('\Magento\Catalog\Helper\Image');
$i = 0;
foreach ($collection as $product) {
echo $product->getName();
}
?>
Comments
Post a Comment