Produced by Araxis Merge on 2021-05-13 09:08:40 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | /Applications/Ampps/www/Porto 3.2.2/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Filterproducts/Block/Home | BestsellersList.php | 2018-01-11 10:49:02 +0000 |
| 2 | /Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Filterproducts/Block/Home | BestsellersList.php | 2020-08-17 03:41:58 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 12 | 154 |
| Changed | 10 | 30 |
| Inserted | 0 | 0 |
| Removed | 1 | 1 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | 2 | |||||
| 3 | namespace Smartwave\Filterproducts\Block\Home; | 3 | namespace Smartwave\Filterproducts\Block\Home; | |||
| 4 | 4 | |||||
| 5 | use Magento\Catalog\Api\CategoryRepositoryInterface; | 5 | use Magento\Catalog\Api\CategoryRepositoryInterface; | |||
| 6 | 6 | |||||
| 7 | class BestsellersList extends \Magento\Catalog\Block\Product\ListProduct { | 7 | class BestsellersList extends \Magento\Catalog\Block\Product\ListProduct { | |||
| 8 | 8 | |||||
| 9 | protected $_collection; | 9 | protected $_collection; | |||
| 10 | 10 | |||||
| 11 | protected $categoryRepository; | 11 | protected $categoryRepository; | |||
| 12 | 12 | |||||
| 13 | protected $_resource; | 13 | protected $_resource; | |||
| 14 | 14 | |||||
| 15 | public function __construct( | 15 | public function __construct( | |||
| 16 | \Magento\Catalog\Block\Product\Context $context, | 16 | \Magento\Catalog\Block\Product\Context $context, | |||
| 17 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | 17 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | |||
| 18 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | 18 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | |||
| 19 | CategoryRepositoryInterface $categoryRepository, | 19 | CategoryRepositoryInterface $categoryRepository, | |||
| 20 | \Magento\Framework\Url\Helper\Data $urlHelper, | 20 | \Magento\Framework\Url\Helper\Data $urlHelper, | |||
| 21 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | 21 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | |||
| 22 | \Magento\Framework\App\ResourceConnection $resource, | 22 | \Magento\Framework\App\ResourceConnection $resource, | |||
| 23 | array $data = [] | 23 | array $data = [] | |||
| 24 | ) { | 24 | ) { | |||
| 25 | $this->categoryRepository = $categoryRepository; | 25 | $this->categoryRepository = $categoryRepository; | |||
| 26 | $this->_collection = $collection; | 26 | $this->_collection = $collection; | |||
| 27 | $this->_resource = $resource; | 27 | $this->_resource = $resource; | |||
| 28 | 28 | |||||
| 29 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | 29 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | |||
| 30 | } | 30 | } | |||
| 31 | 31 | |||||
| 32 | protected function _getProductCollection() { | 32 | protected function _getProductCollection() { | |||
| 33 | return $this->getProducts(); | 33 | return $this->getProducts(); | |||
| 34 | } | 34 | } | |||
| 35 | 35 | |||||
| 36 | public function getProducts() { | 36 | public function getProducts() { | |||
| 37 | $count = $this->getProductCount(); | 37 | $count = $this->getProductCount(); | |||
| 38 | $category_id = $this->getData("category_id"); | 38 | $category_id = $this->getData("category_id"); | |||
| 39 | $collection = clone $this->_collection; | 39 | $collection = clone $this->_collection; | |||
| 40 | $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP)->reset(\Magento\Framework\DB\Select::COLUMNS)->reset('from'); | 40 | $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP)->reset(\Magento\Framework\DB\Select::COLUMNS)->reset('from'); | |||
| 41 | $connection = $this->_resource->getConnection(); | 41 | $collection->getSelect()->join(['e' => $collection->getTable('catalog_product_entity')],''); | |||
| 42 | $collection->getSelect()->join(['e' => $connection->getTableName('catalog_product_entity')],''); | |||||
| 43 | 42 | |||||
| 44 | if(!$category_id) { | 43 | if(!$category_id) { | |||
| 45 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | 44 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | |||
| 46 | } | 45 | } | |||
| 47 | $category = $this->categoryRepository->get($category_id); | 46 | $category = $this->categoryRepository->get($category_id); | |||
| 48 | if(isset($category) && $category) { | 47 | if(isset($category) && $category) { | |||
| 49 | $collection->addMinimalPrice() | 48 | $collection->addMinimalPrice() | |||
| 50 | ->addFinalPrice() | 49 | ->addFinalPrice() | |||
| 51 | ->addTaxPercents() | 50 | ->addTaxPercents() | |||
| 52 | ->addAttributeToSelect('name') | 51 | ->addAttributeToSelect('name') | |||
| 53 | ->addAttributeToSelect('image') | 52 | ->addAttributeToSelect('image') | |||
| 54 | ->addAttributeToSelect('small_image') | 53 | ->addAttributeToSelect('small_image') | |||
| 55 | ->addAttributeToSelect('thumbnail') | 54 | ->addAttributeToSelect('thumbnail') | |||
| 56 | ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) | 55 | ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) | |||
| 57 | ->addUrlRewrite() | 56 | ->addUrlRewrite() | |||
| 58 | ->addAttributeToFilter('is_saleable', 1, 'left') | |||||
| 59 | ->addCategoryFilter($category); | 57 | ->addCategoryFilter($category); | |||
| 60 | } else { | 58 | } else { | |||
| 61 | $collection->addMinimalPrice() | 59 | $collection->addMinimalPrice() | |||
| 62 | ->addFinalPrice() | 60 | ->addFinalPrice() | |||
| 63 | ->addTaxPercents() | 61 | ->addTaxPercents() | |||
| 64 | ->addAttributeToSelect('name') | 62 | ->addAttributeToSelect('name') | |||
| 65 | ->addAttributeToSelect('image') | 63 | ->addAttributeToSelect('image') | |||
| 66 | ->addAttributeToSelect('small_image') | 64 | ->addAttributeToSelect('small_image') | |||
| 67 | ->addAttributeToSelect('thumbnail') | 65 | ->addAttributeToSelect('thumbnail') | |||
| 68 | ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) | 66 | ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) | |||
| 69 | ->addUrlRewrite() | 67 | ->addUrlRewrite(); | |||
| 70 | ->addAttributeToFilter('is_saleable', 1, 'left'); | |||||
| 71 | } | 68 | } | |||
| 72 | 69 | |||||
| 73 | $collection->getSelect() | 70 | $collection->getSelect() | |||
| 74 | ->joinLeft(['soi' => $connection->getTableName('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) | 71 | ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) | |||
| 75 | ->join(['order' => $connection->getTableName('sales_order')], "order.entity_id = soi.order_id",['order.state']) | 72 | ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) | |||
| 76 | ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") | 73 | ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") | |||
| 77 | ->group('soi.product_id') | 74 | ->group('soi.product_id') | |||
| 78 | ->order('ordered_qty DESC') | 75 | ->order('ordered_qty DESC') | |||
| 79 | ->limit($count); | 76 | ->limit($count); | |||
| 80 | 77 | |||||
| 81 | return $collection; | 78 | return $collection; | |||
| 82 | } | 79 | } | |||
| 83 | 80 | |||||
| 84 | public function getLoadedProductCollection() { | 81 | public function getLoadedProductCollection() { | |||
| 85 | return $this->getProducts(); | 82 | return $this->getProducts(); | |||
| 86 | } | 83 | } | |||
| 87 | 84 | |||||
| 88 | public function getProductCount() { | 85 | public function getProductCount() { | |||
| 89 | $limit = $this->getData("product_count"); | 86 | $limit = $this->getData("product_count"); | |||
| 90 | if(!$limit) | 87 | if(!$limit) | |||
| 91 | $limit = 10; | 88 | $limit = 10; | |||
| 92 | return $limit; | 89 | return $limit; | |||
| 93 | } | 90 | } | |||
| 94 | } | 91 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.