6. 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.

6.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/WidgetCarousel.php2023-07-03 06:28:07 +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/WidgetCarousel.php2023-07-03 06:28:07 +0000

6.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged1540
Changed00
Inserted00
Removed00

6.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

6.4 Active regular expressions

No regular expressions were active.

6.5 Comparison detail

1 <?php 1 <?php
2  2 
3 namespace Smartwave\Filterproducts\Block\Widget; 3 namespace Smartwave\Filterproducts\Block\Widget;
4  4 
5 use Magento\Catalog\Api\CategoryRepositoryInterface; 5 use Magento\Catalog\Api\CategoryRepositoryInterface;
6  6 
7  7 
8 class Carousel extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface { 8 class Carousel extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface {
9  9 
10     protected $_collection; 10     protected $_collection;
11  11 
12     protected $categoryRepository; 12     protected $categoryRepository;
13  13 
14     protected $_resource; 14     protected $_resource;
15  15 
16     protected $_pager; 16     protected $_pager;
17  17 
18     private $serializer; 18     private $serializer;
19  19 
20     const DISPLAY_TYPE_PRODUCTS = 'latest_products'; 20     const DISPLAY_TYPE_PRODUCTS = 'latest_products';
21  21 
22     const DEFAULT_SHOW_PAGER = false; 22     const DEFAULT_SHOW_PAGER = false;
23  23 
24     const DEFAULT_PRODUCTS_PER_PAGE = 5; 24     const DEFAULT_PRODUCTS_PER_PAGE = 5;
25  25 
26     const PAGE_VAR_NAME = 'np'; 26     const PAGE_VAR_NAME = 'np';
27  27 
28     public function __construct( 28     public function __construct(
29         \Magento\Catalog\Block\Product\Context $context, 29         \Magento\Catalog\Block\Product\Context $context,
30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper, 30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
31         \Magento\Catalog\Model\Layer\Resolver $layerResolver, 31         \Magento\Catalog\Model\Layer\Resolver $layerResolver,
32         CategoryRepositoryInterface $categoryRepository, 32         CategoryRepositoryInterface $categoryRepository,
33         \Magento\Framework\Url\Helper\Data $urlHelper, 33         \Magento\Framework\Url\Helper\Data $urlHelper,
34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, 34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection,
35         \Magento\Framework\App\ResourceConnection $resource, 35         \Magento\Framework\App\ResourceConnection $resource,
36         array $data = [], 36         array $data = [],
37         \Magento\Framework\Serialize\Serializer\Json $serializer = null 37         \Magento\Framework\Serialize\Serializer\Json $serializer = null
38     ) { 38     ) {
39         $this->categoryRepository = $categoryRepository; 39         $this->categoryRepository = $categoryRepository;
40         $this->_collection = $collection; 40         $this->_collection = $collection;
41         $this->_resource = $resource; 41         $this->_resource = $resource;
42  42 
43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); 43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
44  44 
45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() 45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46             ->get(\Magento\Framework\Serialize\Serializer\Json::class); 46             ->get(\Magento\Framework\Serialize\Serializer\Json::class);
47     } 47     }
48  48 
49     protected function _beforeToHtml() 49     protected function _beforeToHtml()
50     { 50     {
51         $this->setProductCollection($this->createCollection()); 51         $this->setProductCollection($this->createCollection());
52         return parent::_beforeToHtml(); 52         return parent::_beforeToHtml();
53     } 53     }
54  54 
55     public function createCollection() 55     public function createCollection()
56     { 56     {
57       $category_id = ''; 57       $category_id = '';
58       if($this->getData('category_ids')!=''){ 58       if($this->getData('category_ids')!=''){
59         if(explode('/', $this->getData('category_ids'))[0] == 'category'){ 59         if(explode('/', $this->getData('category_ids'))[0] == 'category'){
60           $category_id = explode('/', $this->getData('category_ids'))[1]; 60           $category_id = explode('/', $this->getData('category_ids'))[1];
61         }else{ 61         }else{
62           $category_id = $this->getData('category_ids'); 62           $category_id = $this->getData('category_ids');
63         } 63         }
64       } 64       }
65       $collection = clone $this->_collection; 65       $collection = clone $this->_collection;
66       $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); 66       $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);
67       if(!$category_id) { 67       if(!$category_id) {
68           $category_id = $this->_storeManager->getStore()->getRootCategoryId(); 68           $category_id = $this->_storeManager->getStore()->getRootCategoryId();
69       } 69       }
70       $category = $this->categoryRepository->get($category_id); 70       $category = $this->categoryRepository->get($category_id);
71  71 
72       if ($this->getData('store_id') !== null) { 72       if ($this->getData('store_id') !== null) {
73           $collection->setStoreId($this->getData('store_id')); 73           $collection->setStoreId($this->getData('store_id'));
74       } 74       }
75  75 
76       $collection->addMinimalPrice() 76       $collection->addMinimalPrice()
77           ->addFinalPrice() 77           ->addFinalPrice()
78           ->addTaxPercents() 78           ->addTaxPercents()
79           ->addAttributeToSelect('name') 79           ->addAttributeToSelect('name')
80           ->addAttributeToSelect('image') 80           ->addAttributeToSelect('image')
81           ->addAttributeToSelect('small_image') 81           ->addAttributeToSelect('small_image')
82           ->addAttributeToSelect('thumbnail') 82           ->addAttributeToSelect('thumbnail')
83           ->addAttributeToSelect('special_from_date') 83           ->addAttributeToSelect('special_from_date')
84           ->addAttributeToSelect('special_to_date') 84           ->addAttributeToSelect('special_to_date')
85           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 85           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
86           ->addUrlRewrite() 86           ->addUrlRewrite()
87           ->addStoreFilter(); 87           ->addStoreFilter();
88  88 
89       if(isset($category) && $category) 89       if(isset($category) && $category)
90       { 90       {
91         $collection->addCategoryFilter($category); 91         $collection->addCategoryFilter($category);
92       } 92       }
93       switch ($this->getDisplayType()) 93       switch ($this->getDisplayType())
94       { 94       {
95           case 'new_products': 95           case 'new_products':
96               $collection->addAttributeToFilter( 96               $collection->addAttributeToFilter(
97                     'news_from_date', 97                     'news_from_date',
98                     ['date' => true, 'to' => $this->getEndOfDayDate()], 98                     ['date' => true, 'to' => $this->getEndOfDayDate()],
99                     'left') 99                     'left')
100                 ->addAttributeToFilter( 100                 ->addAttributeToFilter(
101                     'news_to_date', 101                     'news_to_date',
102                     [ 102                     [
103                         'or' => [ 103                         'or' => [
104                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 104                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
105                             1 => ['is' => new \Zend_Db_Expr('null')], 105                             1 => ['is' => new \Zend_Db_Expr('null')],
106                         ] 106                         ]
107                     ], 107                     ],
108                     'left') 108                     'left')
109                 ->addAttributeToSort( 109                 ->addAttributeToSort(
110                     'news_from_date', 110                     'news_from_date',
111                     'desc'); 111                     'desc');
112               break; 112               break;
113           case 'featured_products': 113           case 'featured_products':
114               $collection->addAttributeToFilter('sw_featured', 1, 'left'); 114               $collection->addAttributeToFilter('sw_featured', 1, 'left');
115               break; 115               break;
116           case 'bestseller_products': 116           case 'bestseller_products':
117               $collection->getSelect() 117               $collection->getSelect()
118                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) 118                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty'])
119                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) 119                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state'])
120                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") 120                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL")
121                   ->group('soi.product_id') 121                   ->group('soi.product_id')
122                   ->order('ordered_qty DESC'); 122                   ->order('ordered_qty DESC');
123               break; 123               break;
124           case 'sale_products': 124           case 'sale_products':
125               $collection->addAttributeToFilter('special_price', ['neq' => '']) 125               $collection->addAttributeToFilter('special_price', ['neq' => ''])
126               ->addAttributeToFilter( 126               ->addAttributeToFilter(
127                     'special_from_date', 127                     'special_from_date',
128                     ['date' => true, 'to' => $this->getEndOfDayDate()], 128                     ['date' => true, 'to' => $this->getEndOfDayDate()],
129                     'left') 129                     'left')
130                 ->addAttributeToFilter( 130                 ->addAttributeToFilter(
131                     'special_to_date', 131                     'special_to_date',
132                     [ 132                     [
133                         'or' => [ 133                         'or' => [
134                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 134                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
135                             1 => ['is' => new \Zend_Db_Expr('null')], 135                             1 => ['is' => new \Zend_Db_Expr('null')],
136                         ] 136                         ]
137                     ], 137                     ],
138                     'left') 138                     'left')
139                 ->addAttributeToSort( 139                 ->addAttributeToSort(
140                     'news_from_date', 140                     'news_from_date',
141                     'desc'); 141                     'desc');
142               break; 142               break;
143           case 'deal_products': 143           case 'deal_products':
144               $collection->getSelect() 144               $collection->getSelect()
145                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku') 145                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku')
146                   ->where('dai.sw_deal_enable=1') 146                   ->where('dai.sw_deal_enable=1')
147                   ->where( 147                   ->where(
148                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL' 148                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL'
149                   )->where( 149                   )->where(
150                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL' 150                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL'
151                   ); 151                   );
152               break; 152               break;
153           default: 153           default:
154               $collection->addAttributeToSort('created_at','desc'); 154               $collection->addAttributeToSort('created_at','desc');
155               break; 155               break;
156       } 156       }
157  157 
158       $collection->setPageSize($this->getPageSize()) 158       $collection->setPageSize($this->getPageSize())
159                  ->setCurPage($this->getCurrentPage()); 159                  ->setCurPage($this->getCurrentPage());
160  160 
161       if($this->getDisplayType() == 'featured_products') { 161       if($this->getDisplayType() == 'featured_products') {
162         $collection->getSelect()->order('rand()'); 162         $collection->getSelect()->order('rand()');
163       } 163       }
164       return $collection; 164       return $collection;
165     } 165     }
166  166 
167     public function getCurrentPage() 167     public function getCurrentPage()
168     { 168     {
169         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name'))); 169         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name')));
170     } 170     }
171  171 
172     public function getCacheKeyInfo() 172     public function getCacheKeyInfo()
173     { 173     {
174         return array_merge( 174         return array_merge(
175             parent::getCacheKeyInfo(), 175             parent::getCacheKeyInfo(),
176             [ 176             [
177                 $this->getDisplayType(), 177                 $this->getDisplayType(),
178                 $this->_storeManager->getStore()->getId(), 178                 $this->_storeManager->getStore()->getId(),
179                 $this->getProductsPerPage(), 179                 $this->getProductsPerPage(),
180                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1), 180                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1),
181                 $this->serializer->serialize($this->getRequest()->getParams()) 181                 $this->serializer->serialize($this->getRequest()->getParams())
182             ] 182             ]
183         ); 183         );
184     } 184     }
185  185 
186     public function getDisplayType() 186     public function getDisplayType()
187     { 187     {
188         if (!$this->hasData('display_type')) { 188         if (!$this->hasData('display_type')) {
189             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS); 189             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS);
190         } 190         }
191         return $this->getData('display_type'); 191         return $this->getData('display_type');
192     } 192     }
193  193 
194     public function getProductsCount() 194     public function getProductsCount()
195     { 195     {
196         if (!$this->hasData('product_count')) { 196         if (!$this->hasData('product_count')) {
197             return parent::getProductsCount(); 197             return parent::getProductsCount();
198         } 198         }
199         return $this->getData('product_count'); 199         return $this->getData('product_count');
200     } 200     }
201  201 
202     public function getProductsPerPage() 202     public function getProductsPerPage()
203     { 203     {
204         if (!$this->hasData('products_per_page')) { 204         if (!$this->hasData('products_per_page')) {
205             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE); 205             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE);
206         } 206         }
207         return $this->getData('products_per_page'); 207         return $this->getData('products_per_page');
208     } 208     }
209  209 
210     public function showPager() 210     public function showPager()
211     { 211     {
212         return false; 212         return false;
213     } 213     }
214  214 
215     protected function getPageSize() 215     protected function getPageSize()
216     { 216     {
217         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount(); 217         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount();
218     } 218     }
219  219 
220     public function getPagerHtml() 220     public function getPagerHtml()
221     { 221     {
222         if ($this->showPager()) { 222         if ($this->showPager()) {
223             if (!$this->_pager) { 223             if (!$this->_pager) {
224                 $this->_pager = $this->getLayout()->createBlock( 224                 $this->_pager = $this->getLayout()->createBlock(
225                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class, 225                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class,
226                     $this->getWidgetPagerBlockName() 226                     $this->getWidgetPagerBlockName()
227                 ); 227                 );
228  228 
229                 $this->_pager->setUseContainer(true) 229                 $this->_pager->setUseContainer(true)
230                     ->setShowAmounts(true) 230                     ->setShowAmounts(true)
231                     ->setShowPerPage(false) 231                     ->setShowPerPage(false)
232                     ->setPageVarName($this->getData('page_var_name')) 232                     ->setPageVarName($this->getData('page_var_name'))
233                     ->setLimit($this->getProductsPerPage()) 233                     ->setLimit($this->getProductsPerPage())
234                     ->setTotalLimit($this->getProductsCount()) 234                     ->setTotalLimit($this->getProductsCount())
235                     ->setCollection($this->getProductCollection()); 235                     ->setCollection($this->getProductCollection());
236             } 236             }
237             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) { 237             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) {
238                 return $this->_pager->toHtml(); 238                 return $this->_pager->toHtml();
239             } 239             }
240         } 240         }
241         return ''; 241         return '';
242     } 242     }
243  243 
244     private function getWidgetPagerBlockName() 244     private function getWidgetPagerBlockName()
245     { 245     {
246         $pageName = $this->getData('page_var_name'); 246         $pageName = $this->getData('page_var_name');
247         $pagerBlockName = 'widget.porto.filter.products.carousel.pager'; 247         $pagerBlockName = 'widget.porto.filter.products.carousel.pager';
248  248 
249         if (!$pageName) { 249         if (!$pageName) {
250             return $pagerBlockName; 250             return $pagerBlockName;
251         } 251         }
252  252 
253         return $pagerBlockName . '.' . $pageName; 253         return $pagerBlockName . '.' . $pageName;
254     } 254     }
255  255 
256     public function getDayDate() 256     public function getDayDate()
257     { 257     {
258         return $this->_localeDate->date()->format('Y-m-d H:i:s'); 258         return $this->_localeDate->date()->format('Y-m-d H:i:s');
259     } 259     }
260  260 
261     public function getStartOfDayDate() 261     public function getStartOfDayDate()
262     { 262     {
263         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s'); 263         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s');
264     } 264     }
265  265 
266     public function getEndOfDayDate() 266     public function getEndOfDayDate()
267     { 267     {
268         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s'); 268         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s');
269     } 269     }
270 } 270 }