1. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-11-23 04:31:20 +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.

1.1 Files compared

#LocationFileLast Modified
1/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.6/app/code/Smartwave/Filterproducts/Block/HomeBestsellersList.php2023-06-13 09:00:04 +0000
2/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.7/app/code/Smartwave/Filterproducts/Block/HomeBestsellersList.php2023-11-22 08:10:36 +0000

1.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged6152
Changed426
Inserted12
Removed00

1.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

1.4 Active regular expressions

No regular expressions were active.

1.5 Comparison detail

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)
;
41         $collection->getSelect()->join(['e' => $collection->getTable('catalog_product_entity')],'');    
42  41 
43         if(!$category_id) { 42         if(!$category_id) {
44             $category_id = $this->_storeManager->getStore()->getRootCategoryId(); 43             $category_id = $this->_storeManager->getStore()->getRootCategoryId();
45         } 44         }
46         $category = $this->categoryRepository->get($category_id); 45         $category = $this->categoryRepository->get($category_id);
47         if(isset($category) && $category) { 46 
    47         if ($this->getData('store_id') !== null) {
    48             $collection->setStoreId($this->getData('store_id'));
    49         } 
48             $collection->addMinimalPrice() 50         $collection->addMinimalPrice()
49                 ->addFinalPrice() 51             ->addFinalPrice()
50                 ->addTaxPercents() 52             ->addTaxPercents()
51                 ->addAttributeToSelect('name') 53             ->addAttributeToSelect('name')
52                 ->addAttributeToSelect('image') 54             ->addAttributeToSelect('image')
53                 ->addAttributeToSelect('small_image') 55             ->addAttributeToSelect('small_image')
54                 ->addAttributeToSelect('thumbnail') 56             ->addAttributeToSelect('thumbnail')
    57             ->addAttributeToSelect('special_from_date')
    58             ->addAttributeToSelect('special_to_date')
55                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 59             ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
56                 ->addUrlRewrite() 60             ->addUrlRewrite()
57                 ->addCategoryFilter($category); 61             ->addStoreFilter();
58         } else { 62 
59             $collection->addMinimalPrice() 63         if(isset($category) && $category)
60                 ->addFinalPrice() 64         {
61                 ->addTaxPercents() 65           $collection->addCategoryFilter($category);
62                 ->addAttributeToSelect('name')    
63                 ->addAttributeToSelect('image')    
64                 ->addAttributeToSelect('small_image')    
65                 ->addAttributeToSelect('thumbnail')    
66                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())    
67                 ->addUrlRewrite();    
68         } 66         }
69  67 
70         $collection->getSelect() 68         $collection->getSelect()
71             ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) 69             ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty'])
72             ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) 70             ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state'])
73             ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") 71             ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL")
74             ->group('soi.product_id') 72             ->group('soi.product_id')
75             ->order('ordered_qty DESC') 73             ->order('ordered_qty DESC')
76             ->limit($count); 74             ->limit($count);
77  75 
78         return $collection; 76         return $collection;
79     } 77     }
80  78 
81     public function getLoadedProductCollection() { 79     public function getLoadedProductCollection() {
82         return $this->getProducts(); 80         return $this->getProducts();
83     } 81     }
84  82 
85     public function getProductCount() { 83     public function getProductCount() {
86         $limit = $this->getData("product_count"); 84         $limit = $this->getData("product_count");
87         if(!$limit) 85         if(!$limit)
88             $limit = 10; 86             $limit = 10;
89         return $limit; 87         return $limit;
90     } 88     }
91 } 89 }