Produced by Araxis Merge on 2023-11-23 04:31:23 +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 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.6/app/code/Smartwave/Porto/Helper | Customtabs.php | 2022-09-07 04:10:42 +0000 |
| 2 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.7/app/code/Smartwave/Porto/Helper | Customtabs.php | 2022-09-07 04:10:42 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 1 | 258 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 | namespace Smartwave\Porto\Helper; | 2 | namespace Smartwave\Porto\Helper; | |||
| 3 | 3 | |||||
| 4 | class Customtabs extends \Magento\Framework\App\Helper\AbstractHelper | 4 | class Customtabs extends \Magento\Framework\App\Helper\AbstractHelper | |||
| 5 | { | 5 | { | |||
| 6 | protected $_filterProvider; | 6 | protected $_filterProvider; | |||
| 7 | protected $_storeManager; | 7 | protected $_storeManager; | |||
| 8 | protected $_blockFactory; | 8 | protected $_blockFactory; | |||
| 9 | 9 | |||||
| 10 | public function __construct( | 10 | public function __construct( | |||
| 11 | \Magento\Framework\App\Helper\Context $context, | 11 | \Magento\Framework\App\Helper\Context $context, | |||
| 12 | \Magento\Store\Model\StoreManagerInterface $storeManager, | 12 | \Magento\Store\Model\StoreManagerInterface $storeManager, | |||
| 13 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | 13 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | |||
| 14 | \Magento\Cms\Model\BlockFactory $blockFactory | 14 | \Magento\Cms\Model\BlockFactory $blockFactory | |||
| 15 | ) { | 15 | ) { | |||
| 16 | 16 | |||||
| 17 | $this->_filterProvider = $filterProvider; | 17 | $this->_filterProvider = $filterProvider; | |||
| 18 | $this->_blockFactory = $blockFactory; | 18 | $this->_blockFactory = $blockFactory; | |||
| 19 | $this->_storeManager = $storeManager; | 19 | $this->_storeManager = $storeManager; | |||
| 20 | 20 | |||||
| 21 | parent::__construct($context); | 21 | parent::__construct($context); | |||
| 22 | } | 22 | } | |||
| 23 | 23 | |||||
| 24 | public function getConfig($config_path) | 24 | public function getConfig($config_path) | |||
| 25 | { | 25 | { | |||
| 26 | return $this->scopeConfig->getValue( | 26 | return $this->scopeConfig->getValue( | |||
| 27 | $config_path, | 27 | $config_path, | |||
| 28 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | 28 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | |||
| 29 | ); | 29 | ); | |||
| 30 | } | 30 | } | |||
| 31 | 31 | |||||
| 32 | public function subval_sort($a,$subkey) { | 32 | public function subval_sort($a,$subkey) { | |||
| 33 | foreach($a as $k=>$v) { | 33 | foreach($a as $k=>$v) { | |||
| 34 | $b[$k] = strtolower($v[$subkey]); | 34 | $b[$k] = strtolower($v[$subkey]); | |||
| 35 | } | 35 | } | |||
| 36 | asort($b); | 36 | asort($b); | |||
| 37 | foreach($b as $key=>$val) { | 37 | foreach($b as $key=>$val) { | |||
| 38 | $c[] = $a[$key]; | 38 | $c[] = $a[$key]; | |||
| 39 | } | 39 | } | |||
| 40 | return $c; | 40 | return $c; | |||
| 41 | } | 41 | } | |||
| 42 | public function checkShowingTab($tab_cat_ids, $parent_cat_ids, $tab_prod_skus, $prod_sku) { | 42 | public function checkShowingTab($tab_cat_ids, $parent_cat_ids, $tab_prod_skus, $prod_sku) { | |||
| 43 | » » if(!$tab_cat_ids && !$tab_prod_skus) | 43 | » » if(!$tab_cat_ids && !$tab_prod_skus) | |||
| 44 | return true; | 44 | return true; | |||
| 45 | $tab_cat_ids = explode(",",$tab_cat_ids); | 45 | $tab_cat_ids = explode(",",$tab_cat_ids); | |||
| 46 | $tab_prod_skus = explode(",",$tab_prod_skus); | 46 | $tab_prod_skus = explode(",",$tab_prod_skus); | |||
| 47 | if(count($tab_prod_skus)>0 && count($tab_cat_ids)>0){ | 47 | if(count($tab_prod_skus)>0 && count($tab_cat_ids)>0){ | |||
| 48 | if(in_array($prod_sku, $tab_prod_skus) || count(array_intersect($tab_cat_ids, $parent_cat_ids))>0) | 48 | if(in_array($prod_sku, $tab_prod_skus) || count(array_intersect($tab_cat_ids, $parent_cat_ids))>0) | |||
| 49 | return true; | 49 | return true; | |||
| 50 | } | 50 | } | |||
| 51 | if(count($tab_prod_skus)>0 && in_array($prod_sku, $tab_prod_skus)) | 51 | if(count($tab_prod_skus)>0 && in_array($prod_sku, $tab_prod_skus)) | |||
| 52 | return true; | 52 | return true; | |||
| 53 | if(count($tab_cat_ids)>0 && count(array_intersect($tab_cat_ids, $parent_cat_ids))>0) | 53 | if(count($tab_cat_ids)>0 && count(array_intersect($tab_cat_ids, $parent_cat_ids))>0) | |||
| 54 | return true; | 54 | return true; | |||
| 55 | 55 | |||||
| 56 | return false; | 56 | return false; | |||
| 57 | } | 57 | } | |||
| 58 | 58 | |||||
| 59 | public function getBlockContent($content = '') { | 59 | public function getBlockContent($content = '') { | |||
| 60 | if(!$this->_filterProvider) | 60 | if(!$this->_filterProvider) | |||
| 61 | return $content; | 61 | return $content; | |||
| 62 | return $this->_filterProvider->getBlockFilter()->filter(trim($content)); | 62 | return $this->_filterProvider->getBlockFilter()->filter(trim($content)); | |||
| 63 | } | 63 | } | |||
| 64 | public function getCustomTabs($product){ | 64 | public function getCustomTabs($product){ | |||
| 65 | $cms_tabs = $this->getConfig('porto_settings/product/custom_cms_tabs') ? $this->getConfig('porto_settings/product/custom_cms_tabs') : ''; | 65 | $cms_tabs = $this->getConfig('porto_settings/product/custom_cms_tabs') ? $this->getConfig('porto_settings/product/custom_cms_tabs') : ''; | |||
| 66 | $attr_tabs = $this->getConfig('porto_settings/product/custom_attr_tabs') ? $this->getConfig('porto_settings/product/custom_attr_tabs') : ''; | 66 | $attr_tabs = $this->getConfig('porto_settings/product/custom_attr_tabs') ? $this->getConfig('porto_settings/product/custom_attr_tabs') : ''; | |||
| 67 | $_sku = $product->getSku(); | 67 | $_sku = $product->getSku(); | |||
| 68 | if($cms_tabs) | 68 | if($cms_tabs) | |||
| 69 | $cms_tabs = unserialize($cms_tabs); | 69 | $cms_tabs = unserialize($cms_tabs); | |||
| 70 | if($attr_tabs) | 70 | if($attr_tabs) | |||
| 71 | $attr_tabs = unserialize($attr_tabs); | 71 | $attr_tabs = unserialize($attr_tabs); | |||
| 72 | $parents = array(); | 72 | $parents = array(); | |||
| 73 | if(count($cms_tabs)>0 || count($attr_tabs)>0) { | 73 | if(count($cms_tabs)>0 || count($attr_tabs)>0) { | |||
| 74 | foreach($product->getCategoryCollection() as $parent_cat) { | 74 | foreach($product->getCategoryCollection() as $parent_cat) { | |||
| 75 | $parents[] = $parent_cat->getId(); | 75 | $parents[] = $parent_cat->getId(); | |||
| 76 | } | 76 | } | |||
| 77 | } | 77 | } | |||
| 78 | $store_id = $this->_storeManager->getStore()->getId(); | 78 | $store_id = $this->_storeManager->getStore()->getId(); | |||
| 79 | $custom_tabs = array(); | 79 | $custom_tabs = array(); | |||
| 80 | if(count($cms_tabs)>0){ | 80 | if(count($cms_tabs)>0){ | |||
| 81 | foreach($cms_tabs as $_item) { | 81 | foreach($cms_tabs as $_item) { | |||
| 82 | if($this->checkShowingTab($_item['category_ids'],$parents,$_item['product_skus'],$_sku)){ | 82 | if($this->checkShowingTab($_item['category_ids'],$parents,$_item['product_skus'],$_sku)){ | |||
| 83 | $block_id = $_item['staticblock_id']; | 83 | $block_id = $_item['staticblock_id']; | |||
| 84 | if(!$block_id) | 84 | if(!$block_id) | |||
| 85 | continue; | 85 | continue; | |||
| 86 | $block = $this->_blockFactory->create(); | 86 | $block = $this->_blockFactory->create(); | |||
| 87 | $block->setStoreId($store_id)->load($block_id); | 87 | $block->setStoreId($store_id)->load($block_id); | |||
| 88 | 88 | |||||
| 89 | if(!$block) continue; | 89 | if(!$block) continue; | |||
| 90 | 90 | |||||
| 91 | $block_content = $block->getContent(); | 91 | $block_content = $block->getContent(); | |||
| 92 | 92 | |||||
| 93 | if(!$block_content) continue; | 93 | if(!$block_content) continue; | |||
| 94 | 94 | |||||
| 95 | $content = $this->_filterProvider->getBlockFilter()->setStoreId($store_id)->filter($block_content); | 95 | $content = $this->_filterProvider->getBlockFilter()->setStoreId($store_id)->filter($block_content); | |||
| 96 | $arr = array(); | 96 | $arr = array(); | |||
| 97 | $arr['tab_title'] = $_item['tab_title']; | 97 | $arr['tab_title'] = $_item['tab_title']; | |||
| 98 | $arr['tab_content'] = $content; | 98 | $arr['tab_content'] = $content; | |||
| 99 | $arr['sort_order'] = (!$_item['sort_order'] || !is_numeric($_item['sort_order']))?0:$_item['sort_order']; | 99 | $arr['sort_order'] = (!$_item['sort_order'] || !is_numeric($_item['sort_order']))?0:$_item['sort_order']; | |||
| 100 | $custom_tabs[] = $arr; | 100 | $custom_tabs[] = $arr; | |||
| 101 | } | 101 | } | |||
| 102 | } | 102 | } | |||
| 103 | } | 103 | } | |||
| 104 | if(count($attr_tabs)>0){ | 104 | if(count($attr_tabs)>0){ | |||
| 105 | foreach($attr_tabs as $_item) { | 105 | foreach($attr_tabs as $_item) { | |||
| 106 | if($this->checkShowingTab($_item['category_ids'],$parents,$_item['product_skus'],$_sku)){ | 106 | if($this->checkShowingTab($_item['category_ids'],$parents,$_item['product_skus'],$_sku)){ | |||
| 107 | $attr_code = $_item['attribute_code']; | 107 | $attr_code = $_item['attribute_code']; | |||
| 108 | 108 | |||||
| 109 | $attribute = $product->getResource()->getAttribute($attr_code); | 109 | $attribute = $product->getResource()->getAttribute($attr_code); | |||
| 110 | if(!$attribute) | 110 | if(!$attribute) | |||
| 111 | continue; | 111 | continue; | |||
| 112 | $attr_value = $attribute->getFrontend()->getValue($product); | 112 | $attr_value = $attribute->getFrontend()->getValue($product); | |||
| 113 | if(!$attr_value) continue; | 113 | if(!$attr_value) continue; | |||
| 114 | 114 | |||||
| 115 | $content = $this->_filterProvider->getBlockFilter()->setStoreId($store_id)->filter($attr_value); | 115 | $content = $this->_filterProvider->getBlockFilter()->setStoreId($store_id)->filter($attr_value); | |||
| 116 | $arr = array(); | 116 | $arr = array(); | |||
| 117 | $arr['tab_title'] = $_item['tab_title']; | 117 | $arr['tab_title'] = $_item['tab_title']; | |||
| 118 | $arr['tab_content'] = $content; | 118 | $arr['tab_content'] = $content; | |||
| 119 | $arr['sort_order'] = (!$_item['sort_order'] || !is_numeric($_item['sort_order']))?0:$_item['sort_order']; | 119 | $arr['sort_order'] = (!$_item['sort_order'] || !is_numeric($_item['sort_order']))?0:$_item['sort_order']; | |||
| 120 | $custom_tabs[] = $arr; | 120 | $custom_tabs[] = $arr; | |||
| 121 | } | 121 | } | |||
| 122 | } | 122 | } | |||
| 123 | } | 123 | } | |||
| 124 | if(count($custom_tabs)>0) | 124 | if(count($custom_tabs)>0) | |||
| 125 | $custom_tabs = $this->subval_sort($custom_tabs,'sort_order'); | 125 | $custom_tabs = $this->subval_sort($custom_tabs,'sort_order'); | |||
| 126 | 126 | |||||
| 127 | return $custom_tabs; | 127 | return $custom_tabs; | |||
| 128 | } | 128 | } | |||
| 129 | } | 129 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.