This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml;
/**
* Class Debugger
* @package WeltPixel\Backend\Block\Adminhtml
*/
class Debugger extends \Magento\Backend\Block\Widget\Grid\Container
{
protected function _construct()
{
$this->_controller = 'weltpixelbackend_debugger';
$this->_blockGroup = 'WeltPixel_Backend';
parent::_construct();
$this->removeButton('add');
$this->addButton(
'only-custom',
[
'label' => __("Only Custom Modules"),
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/rewritescustom') . '\')',
'class' => 'primary'
]
);
$this->addButton(
'all-core',
[
'label' => __("All Magento Modules"),
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/rewritesall') . '\')',
'class' => 'secondary'
]
);
}
}
@@ -0,0 +1,28 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml\Grid\Renderer;
/**
* Class RewriteStatus
* @package WeltPixel\Backend\Block\Adminhtml\Grid\Renderer
*/
class RewriteStatus extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
* Prepare link to display in grid
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
$statusClass = 'ok';
$statusMessage = __('OK');
if (!$row->getStatus()) {
$statusClass = 'nok';
$statusMessage = __('CHECK REWRITE');
}
return '<span class="rewrite-status rewrite-status-'.$statusClass.'">' . $statusMessage .'</span>';
}
}
@@ -0,0 +1,15 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
/**
* Class Extensions
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
*/
class Extensions extends \Magento\Config\Block\System\Config\Form\Fieldset
{
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
return '<iframe id="weltpixel_store" width="100%" src="https://www.weltpixel.com/store/index.html?id=' . uniqid() .'" ></iframe>';
}
}
@@ -0,0 +1,25 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_Backend
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\Backend\Block\Adminhtml\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
/**
* Class Disable
* @package WeltPixel\Backend\Block\System\Config\Form\Field
*/
class Disable extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getElementHtml(AbstractElement $element)
{
$element->setDisabled('disabled');
return $element->getElementHtml();
}
}
@@ -0,0 +1,24 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_Backend
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\Backend\Block\Adminhtml\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
/**
* Class EmptyField
* @package WeltPixel\Backend\Block\System\Config\Form\Field
*/
class EmptyField extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getElementHtml(AbstractElement $element)
{
return '';
}
}
@@ -0,0 +1,23 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
/**
* Class Notification
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
*/
class Notification extends Field
{
protected $_template = 'WeltPixel_Backend::system/config/notification.phtml';
/**
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
}
@@ -0,0 +1,37 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
/**
* Class SystemInformation
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
*/
class SystemInformation extends Field
{
protected $_template = 'WeltPixel_Backend::system/config/information.phtml';
/**
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
/**
* @return string
*/
public function getMagentoMode() {
return $this->_appState->getMode();
}
/**
* @return string
*/
public function getMagentoPath() {
return $this->getRootDirectory()->getAbsolutePath();
}
}
@@ -0,0 +1,41 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml;
abstract class Debugger extends \Magento\Backend\App\Action
{
/**
* Authorization level of a basic admin session
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger';
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
*/
public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry)
{
$this->_coreRegistry = $coreRegistry;
parent::__construct($context);
}
/**
* Init page
*
* @param \Magento\Backend\Model\View\Result\Page $resultPage
* @return \Magento\Backend\Model\View\Result\Page
*/
protected function initPage($resultPage)
{
$resultPage->setActiveMenu('WeltPixel_Backend::WeltPixel_Debugger');
return $resultPage;
}
}
@@ -0,0 +1,39 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
class Rewrites extends \WeltPixel\Backend\Controller\Adminhtml\Debugger
{
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger';
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context, $coreRegistry);
}
/**
* Index action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Check Rewrites / Preferences'));
return $resultPage;
}
}
@@ -0,0 +1,36 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
class Rewritesall extends \WeltPixel\Backend\Controller\Adminhtml\Debugger\Rewrites
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context, $coreRegistry, $resultPageFactory);
}
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->_session->setDebuggerRewite(true);
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/rewrites');
}
}
@@ -0,0 +1,36 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
class Rewritescustom extends \WeltPixel\Backend\Controller\Adminhtml\Debugger\Rewrites
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context, $coreRegistry, $resultPageFactory);
}
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->_session->setDebuggerRewite(false);
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/rewrites');
}
}
+4
View File
@@ -0,0 +1,4 @@
Important notes:
- Extension files for Magento versions 2.4 or higher.
- Files NOT compatible with Magento version 2.0 - 2.3.x.
- Using different set of files for each Magento version for best performance.
+136
View File
@@ -0,0 +1,136 @@
<?php
namespace WeltPixel\Backend\Helper;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Cron\Model\ScheduleFactory;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Developer extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* @var ProductMetadataInterface
*/
protected $productMetaData;
/**
* @var ScheduleFactory
*/
protected $scheduleFactory;
/**
* @var \Magento\Framework\Stdlib\DateTime\DateTime
*/
protected $dateTime;
/**
* @var \Magento\Framework\Component\ComponentRegistrarInterface
*/
protected $componentRegistrar;
/**
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
*/
protected $readFactory;
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ProductMetadataInterface $productMetadata
* @param ScheduleFactory $scheduleFactory
* @param \Magento\Framework\Stdlib\DateTime\DateTime $datetime
* @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ProductMetadataInterface $productMetadata,
ScheduleFactory $scheduleFactory,
\Magento\Framework\Stdlib\DateTime\DateTime $datetime,
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar,
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
)
{
parent::__construct($context);
$this->productMetaData = $productMetadata;
$this->scheduleFactory = $scheduleFactory;
$this->dateTime = $datetime;
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
}
/**
* @return string
*/
public function getCurrentServerUser()
{
if (function_exists('get_current_user')) {
return get_current_user();
}
// Try POSIX (Linux/Unix)
if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
$userInfo = posix_getpwuid(posix_geteuid());
if (!empty($userInfo['name'])) {
return $userInfo['name'];
}
}
// Try environment variables
$user = getenv('USER') ?: getenv('USERNAME');
if (!empty($user)) {
return $user;
}
// Fallback: unknown
return 'unknown';
}
/**
* @return string
*/
public function getCurrentServerUserGroup()
{
if (function_exists('posix_getegid')) {
$groupid = posix_getegid();
$groupinfo = posix_getgrgid($groupid);
if (is_array($groupinfo)) {
return $groupinfo['name'];
}
}
return '-';
}
/**
* @return string
*/
public function getMagentoEdition()
{
return $this->productMetaData->getEdition() . ' ( ' . $this->productMetaData->getVersion() . ' )';
}
/**
* @param int $pageSize
* @return \Magento\Cron\Model\ResourceModel\Schedule\Collection mixed
*/
public function getLatestCronJobs($pageSize)
{
$scheduleCollection = $this->scheduleFactory->create()->getCollection();
$scheduleCollection->setOrder('schedule_id', 'DESC')
->setPageSize($pageSize);
return $scheduleCollection;
}
/**
* @return string
*/
public function getServerTime()
{
return $this->dateTime->gmtDate();
}
}
+141
View File
@@ -0,0 +1,141 @@
<?php
namespace WeltPixel\Backend\Helper;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use \Magento\Store\Api\StoreRepositoryInterface;
use \Magento\Store\Model\StoreManagerInterface;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Utility extends \Magento\Framework\App\Helper\AbstractHelper
{
/** @var ThemeProviderInterface */
protected $themeProvider;
/** @var StoreRepositoryInterface */
protected $storeRepository;
/**
* @var StoreManagerInterface
*/
protected $storeManager;
/** @var array */
protected $storeThemesLocales = [];
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ThemeProviderInterface $themeProvider
* @param StoreRepositoryInterface $storeRepository
* @param StoreManagerInterface $storeManager
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ThemeProviderInterface $themeProvider,
StoreRepositoryInterface $storeRepository,
StoreManagerInterface $storeManager
)
{
parent::__construct($context);
$this->themeProvider = $themeProvider;
$this->storeRepository = $storeRepository;
$this->storeManager = $storeManager;
}
public function isPearlThemeUsed($storeCode = null)
{
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$theme = $this->themeProvider->getThemeById($themeId);
$isPearlTheme = $this->_validatePearlTheme($theme);
return $isPearlTheme;
}
/**
* @param \Magento\Theme\Model\Theme $theme
* @return bool
*/
protected function _validatePearlTheme($theme)
{
$pearlThemePath = 'Pearl/weltpixel';
do {
if ($theme->getThemePath() == $pearlThemePath) {
return true;
}
$theme = $theme->getParentTheme();
} while ($theme);
return false;
}
/**
* @return array
*/
public function getStoreThemesLocales() {
if (count($this->storeThemesLocales)) {
return $this->storeThemesLocales;
}
$stores = $this->storeRepository->getList();
$result = [];
$isSingleStoreMode = $this->storeManager->isSingleStoreMode();
foreach ($stores as $store) {
$storeId = $store["store_id"];
$websiteId = $store["website_id"];
if (!$storeId) continue;
$storeCode = $store["code"];
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
$locale = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeCode
);
if ($isSingleStoreMode) {
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
$websiteId
);
$locale = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
$websiteId
);
}
$theme = $this->themeProvider->getThemeById($themeId);
$result[$theme->getThemePath().'/'.$locale] = $storeCode;
}
$this->storeThemesLocales = $result;
return $this->storeThemesLocales;
}
/**
* @return false|\Magento\Csp\Helper\CspNonceProvider
*/
public function getCspNonceProvider()
{
if (class_exists(\Magento\Csp\Helper\CspNonceProvider::class)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Csp\Helper\CspNonceProvider::class);
}
return false;
}
}
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2025 WeltPixel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace WeltPixel\Backend\Model\Config\Source;
/**
* @api
* @since 100.0.2
*/
class Yesno implements \Magento\Framework\Option\ArrayInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [['value' => 1, 'label' => __('Yes (Recommended)')], ['value' => 0, 'label' => __('No')]];
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return [0 => __('No'), 1 => __('Yes (Recommended)')];
}
}
@@ -0,0 +1,227 @@
<?php
namespace WeltPixel\Backend\Model\ResourceModel\Debugger\Grid;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Search\AggregationInterface;
/**
* Class Collection
* @package WeltPixel\Bakcend\Model\ResourceModel\Debugger\Grid
*/
class Collection extends \Magento\Framework\Data\Collection implements SearchResultInterface
{
/**
* @var AggregationInterface
*/
protected $aggregations;
/**
* @var \WeltPixel\Backend\Model\Scanner
*/
protected $scanner;
/**
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;
/**
* @var \Magento\Framework\DataObjectFactory
*/
protected $_dataObjectFactory;
/**
* @param \Magento\Backend\Model\Session $backendSession
* @param \WeltPixel\Backend\Model\Scanner $scanner
* @param \Magento\Framework\DataObjectFactory $dataObjectFactory
* @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Backend\Model\Session $backendSession,
\WeltPixel\Backend\Model\Scanner $scanner,
\Magento\Framework\DataObjectFactory $dataObjectFactory,
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
)
{
parent::__construct(
$entityFactory
);
$this->_dataObjectFactory = $dataObjectFactory;
$this->scanner = $scanner;
$this->backendSession = $backendSession;
}
/**
* @return AggregationInterface
*/
public function getAggregations()
{
return $this->aggregations;
}
/**
* @param AggregationInterface $aggregations
* @return $this
*/
public function setAggregations($aggregations)
{
$this->aggregations = $aggregations;
}
/**
* Retrieve all ids for collection
* Backward compatibility with EAV collection
*
* @param int $limit
* @param int $offset
* @return array
*/
public function getAllIds($limit = null, $offset = null)
{
return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
}
/**
* Get search criteria.
*
* @return \Magento\Framework\Api\SearchCriteriaInterface|null
*/
public function getSearchCriteria()
{
return null;
}
/**
* Set search criteria.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setSearchCriteria(?\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
{
return $this;
}
/**
* Get total count.
*
* @return int
*/
public function getTotalCount()
{
return $this->getSize();
}
/**
* Set total count.
*
* @param int $totalCount
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setTotalCount($totalCount)
{
return $this;
}
/**
* Set items list.
*
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setItems(?array $items = null)
{
return $this;
}
/**
* @return \Magento\Framework\DataObject[]
*/
public function getItems()
{
$this->_populateCollection();
return parent::getItems();
}
public function _populateCollection()
{
$rewritesOption = $this->backendSession->getDebuggerRewite(false);
$rewrites = $this->scanner->getRewrites($rewritesOption);
$filterCondition = $this->scanner->getData('filterCondition') ?? '';
$searchKey = str_replace("\\\\\\\\", "\\", $filterCondition);
if ($searchKey) {
foreach ($rewrites as $key => $value) {
if (strpos(strtolower($key), strtolower($searchKey)) === false) {
unset($rewrites[$key]);
}
}
}
foreach ($rewrites as $originalClass => $rewriteOptions) {
foreach ($rewriteOptions as $areaCode => $rewriteClasses) {
if (count($rewriteClasses) > 1) {
$status = false;
} else {
$status = true;
}
/**
* Exceptions
* Magento\Catalog\Block\Product\ImageBuilder class we rewrite in LazyLoading, OwlCarousel modules as well
* these modules are sold as standalone ones, so we rewrite the class also in CategoryPage module
* where we merge the functionalities from those 2 modules, in this case this rewrite is marked as Ok,
*/
if (($originalClass == 'Magento\Catalog\Block\Product\ImageFactory') &&
($areaCode == 'frontend')
) {
$checkRewriteStatus = true;
foreach ($rewriteClasses as $className) {
if (strpos($className, 'WeltPixel\\') === false ) {
$checkRewriteStatus = false;
}
}
$status = $checkRewriteStatus;
}
foreach ($rewriteClasses as $key => $rewriteClass) {
$item = $this->_dataObjectFactory->create();
if ($key) {
$item->setArea('');
$item->setOriginalClass('');
} else {
$item->setArea($areaCode);
$item->setOriginalClass($originalClass);
}
$item->setRewriteClass($rewriteClass);
$item->setStatus($status);
$this->addItem($item);
}
}
}
}
/**
* Filter applied only on the original_class column
*
* @param array|string $field
* @param array|int|string $condition
* @return $this
*/
public function addFieldToFilter($field, $condition)
{
$conditionValue = substr($condition['like'], 2, -2);
$this->scanner->setData('filterCondition', $conditionValue);
return $this;
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
namespace WeltPixel\Backend\Model;
class Scanner extends \Magento\Framework\Model\AbstractModel
{
/**
* @var \Magento\Framework\App\Config\FileResolver
*/
protected $fileResolver;
/**
* @var \Magento\Framework\App\AreaList
*/
protected $areaList;
/**
* Direct usage of \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner
* caused error on compilation
* Argument 1 passed to Magento\\Setup\\Module\\Di\\Code\\Scanner\\ConfigurationScanner::__construct()
* must be an instance of Magento\\Framework\\App\\Config\\FileResolver,
* instance of Magento\\Framework\\ObjectManager\\ObjectManager given
*
* so FileResolver and AreaList injected directly insetad
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\FileResolver $fileResolver
* @param \Magento\Framework\App\AreaList $areaList
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\FileResolver $fileResolver,
\Magento\Framework\App\AreaList $areaList
)
{
parent::__construct($context, $registry);
$this->fileResolver = $fileResolver;
$this->areaList = $areaList;
}
/**
* \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner scan usage,
* because the original class injection is causing error on compilation
*
* @param $fileName
* @return array
*/
public function getScannedFiles($fileName) {
$files = [];
$areaCodes = array_merge(
['primary', \Magento\Framework\App\Area::AREA_GLOBAL],
$this->areaList->getCodes()
);
foreach ($areaCodes as $area) {
$files = array_merge_recursive(
$files,
$this->fileResolver->get($fileName, $area)->toArray()
);
}
return array_keys($files);
}
/**
* @param bool $all
* @return array
*/
public function getRewrites($all = false)
{
$diFiles = $this->getScannedFiles('di.xml');
$moduleFiles = $this->getScannedFiles('module.xml');
array_walk($moduleFiles, function (&$item) {
$item = str_replace('/module.xml', '', $item);
});
if (!$all) {
foreach ($diFiles as $key => $file) {
preg_match('/(.*\/etc)/', $file, $matches);
$resultKey = $matches[1];
if (!in_array($resultKey, $moduleFiles) ||
(strpos($file, '/vendor/magento') !== false)
) {
unset($diFiles[$key]);
}
}
}
$rewrites = $this->_collectRewriteEntities($diFiles);
return $rewrites;
}
/**
* @param array $files
* @return array
*/
protected function _collectRewriteEntities(array $files)
{
$rewrites = [];
foreach ($files as $fileName) {
$areaCode = 'global';
preg_match('/\/etc\/(.*)\/di.xml/', $fileName, $matches);
if (isset($matches[1])) {
$areaCode = $matches[1];
}
$dom = new \DOMDocument();
$dom->loadXML(file_get_contents($fileName));
$xpath = new \DOMXPath($dom);
/** @var $node \DOMNode */
foreach ($xpath->query('//preference') as $node) {
$originalClass = $node->getAttribute('for');
$rewriteClass = $node->getAttribute('type');
if (!isset($rewrites[$originalClass]) || !isset($rewrites[$originalClass][$areaCode]) || !in_array($rewriteClass, $rewrites[$originalClass][$areaCode])) {
$rewrites[$originalClass][$areaCode][] = $rewriteClass;
}
}
}
return $rewrites;
}
}
@@ -0,0 +1,80 @@
<?php
namespace WeltPixel\Backend\Plugin\Category;
use Magento\Eav\Model\Config;
use Magento\Framework\App\Request\Http as HttpRequest;
class DataProvider
{
/**
* @var Config
*/
private $eavConfig;
/**
* @var HttpRequest
*/
private $request;
/**
* DataProvider constructor.
* @param Config $eavConfig
* @param HttpRequest $request
*/
public function __construct(
Config $eavConfig,
HttpRequest $request
) {
$this->eavConfig = $eavConfig;
$this->request = $request;
}
/**
* @param \Magento\Catalog\Model\Category\DataProvider $subject
* @param array $result
* @return array
*/
public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
{
$fullActionName = $this->request->getFullActionName();
if ($fullActionName == 'catalog_category_edit') {
$result = array_merge_recursive($result, $this->_prepareFieldsMeta(
$result,
$this->_getFieldsMap(),
$subject->getAttributesMeta($this->eavConfig->getEntityType('catalog_category'))
));
}
return $result;
}
/**
* Prepare fields meta based on xml declaration of form and fields metadata
*
* @param array $originalResult
* @param array $fieldsMap
* @param array $fieldsMeta
* @return array
*/
protected function _prepareFieldsMeta($originalResult, $fieldsMap, $fieldsMeta)
{
$result = [];
foreach ($fieldsMap as $fieldSet => $fields) {
foreach ($fields as $field) {
if (isset($fieldsMeta[$field]) && (!isset($originalResult[$fieldSet]['children'][$field]))) {
$result[$fieldSet]['children'][$field]['arguments']['data']['config'] = $fieldsMeta[$field];
}
}
}
return $result;
}
/**
* Rewrite this in all subclassess, provide the list with category attributes
* @return array
*/
protected function _getFieldsMap()
{
return [];
}
}
@@ -0,0 +1,17 @@
<?php
namespace WeltPixel\Backend\Plugin\CategoryStaging;
class DataProvider
{
/**
* @param \Magento\Catalog\Model\Category\DataProvider $subject
* @param array $result
* @return array
*/
public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
{
unset($result['weltpixel_options']);
unset($result['weltpixel_megamenu']);
return $result;
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace WeltPixel\Backend\Plugin;
use Magento\Framework\App\Config\ScopeConfigInterface;
class ScopeConfig
{
public function afterIsSetFlag(
ScopeConfigInterface $subject,
$result,
$path,
$scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$scopeCode = null
) {
if ($path == 'csp/mode/storefront/report_only') {
if ($subject->getValue('weltpixel_backend_developer/csp/change_system_value')) {
$result = (boolean) $subject->getValue('weltpixel_backend_developer/csp/report_only');
}
}
return $result;
}
public function afterGetValue(
ScopeConfigInterface $subject,
$result,
$path,
$scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$scopeCode = null
) {
if (preg_match('/^csp\/mode\/storefront_[^\/]+\/report_only$/', $path)) {
if ($subject->getValue('weltpixel_backend_developer/csp/change_system_value')) {
$result = (boolean) $subject->getValue('weltpixel_backend_developer/csp/report_only');
}
}
return $result;
}
}
+22
View File
@@ -0,0 +1,22 @@
# magento2-weltpixel-backend
### Installation
With composer:
```sh
$ composer config repositories.weltpixel-magento2-weltpixel-backend git https://github.com/Weltpixel/magento2-weltpixel-backend.git
$ composer require weltpixel/magento2-weltpixel-backend:dev-master
```
Manually:
Copy the zip into the app/code/WeltPixel/Backend directory
#### After installation by either means, enable the extension by running following commands:
```sh
$ php bin/magento module:enable WeltPixel_Backend --clear-static-content
$ php bin/magento setup:upgrade
```
@@ -0,0 +1,83 @@
<?php
namespace WeltPixel\Backend\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
class GenerateCronExpression implements DataPatchInterface, PatchVersionInterface
{
const UPDATE_CRON_STRING_PATH = "weltpixel/crontab/license";
/** @var WriterInterface */
private $configWriter;
/**
* @var ModuleDataSetupInterface $moduleDataSetup
*/
private $moduleDataSetup;
/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param WriterInterface $configWriter
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
WriterInterface $configWriter)
{
$this->moduleDataSetup = $moduleDataSetup;
$this->configWriter = $configWriter;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$this->moduleDataSetup->startSetup();
$cronExpression = $this->_generateCronExpression();
$this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $cronExpression);
$this->moduleDataSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.1.1';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
/**
* @return string
*/
protected function _generateCronExpression()
{
$minute = rand(0, 59);
$hour = rand(-2, 6);
$dayOfWeek = rand(0, 6);
if ($hour < 0) {
$hour += 24;
}
return $minute . ' ' . $hour . ' * * ' . $dayOfWeek;
}
}
@@ -0,0 +1,85 @@
<?php
namespace WeltPixel\Backend\Setup\Patch\Schema;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class AddLicenseTable implements SchemaPatchInterface, PatchVersionInterface
{
/**
* @var SchemaSetupInterface $schemaSetup
*/
private $schemaSetup;
/**
* @param SchemaSetupInterface $schemaSetup
*/
public function __construct(SchemaSetupInterface $schemaSetup)
{
$this->schemaSetup = $schemaSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$installer = $this->schemaSetup;
$this->schemaSetup->startSetup();
/**
* Create table 'weltpixel_license'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('weltpixel_license')
)->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Id'
)->addColumn(
'module_name',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'Module Name'
)->addColumn(
'license_key',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
1024,
[],
'License Key'
)->setComment(
'WeltPixel License'
);
$installer->getConnection()->createTable($table);
$this->schemaSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.1.1';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"name": "weltpixel/magento2-weltpixel-backend",
"description": "WeltPixel Backend Module",
"require": {
"magento/module-admin-notification": "*"
},
"type": "magento2-module",
"version": "1.16.0",
"license": "MIT",
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"WeltPixel\\Backend\\": ""
}
}
}
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin" >
<resource id="WeltPixel_Backend::WeltPixel" title="WeltPixel" sortOrder="200" >
<resource id="WeltPixel_Backend::WeltPixel_HelpCenter" title="WeltPixel HelpCenter" sortOrder="2" />
<resource id="WeltPixel_Backend::WeltPixel_Debugger" title="WeltPixel Debugger" sortOrder="5" >
<resource id="WeltPixel_Backend::WeltPixel_Debugger_Rewrites" title="Rewrites" sortOrder="1" />
<resource id="WeltPixel_Backend::WeltPixel_Debugger_Modules" title="Extensions Version" sortOrder="5" />
<resource id="WeltPixel_Backend::WeltPixel_Debugger_Developer" title="Developer" sortOrder="25" />
</resource>
<resource id="WeltPixel_Backend::Pearl_Theme_Options" title="Pearl Theme Options" sortOrder="5" />
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="WeltPixel_Backend::DocumentationSettings" title="WeltPixel DocumentationSettings" sortOrder="0" />
<resource id="WeltPixel_Backend::DeveloperSettings" title="WeltPixel Developer" sortOrder="1000" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\CatalogStaging\Model\Category\DataProvider">
<plugin name="weltpixel-backend-categorystaging-dataprovider" type="WeltPixel\Backend\Plugin\CategoryStaging\DataProvider" sortOrder="1" />
</type>
</config>
+55
View File
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="WeltPixel_Backend::WeltPixel" title="WeltPixel" module="WeltPixel_Backend" sortOrder="200" resource="WeltPixel_Backend::WeltPixel"/>
<add
id="WeltPixel_Backend::WeltPixel_HelpCenter"
title="WeltPixel Help Center"
module="WeltPixel_Backend"
action="adminhtml/system_config/edit/section/weltpixel_backend_config/"
sortOrder="1"
parent="WeltPixel_Backend::WeltPixel"
resource="WeltPixel_Backend::WeltPixel_HelpCenter"
/>
<add
id="WeltPixel_Backend::WeltPixel_Debugger"
title="WeltPixel Debugger"
module="WeltPixel_Backend"
sortOrder="3"
parent="WeltPixel_Backend::WeltPixel"
resource="WeltPixel_Backend::WeltPixel_Debugger"
/>
<add
id="WeltPixel_Backend::WeltPixel_Debugger_Rewrites"
title="Rewrites"
module="WeltPixel_Backend"
action="weltpixel_backend/debugger/rewrites"
sortOrder="2"
parent="WeltPixel_Backend::WeltPixel_Debugger"
resource="WeltPixel_Backend::WeltPixel_Debugger_Rewrites"
/>
<add
id="WeltPixel_Backend::WeltPixel_Debugger_Developer"
title="Developer"
module="WeltPixel_Backend"
action="adminhtml/system_config/edit/section/weltpixel_backend_developer/"
sortOrder="25"
parent="WeltPixel_Backend::WeltPixel_Debugger"
resource="WeltPixel_Backend::WeltPixel_Debugger_Developer"
/>
<add
id="WeltPixel_Backend::Pearl_Theme_Options"
title="Pearl Theme Options"
module="WeltPixel_Backend"
sortOrder="3"
parent="WeltPixel_Backend::WeltPixel"
resource="WeltPixel_Backend::Pearl_Theme_Options"
/>
</menu>
</config>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="weltpixel_backend" frontName="weltpixel_backend">
<module name="WeltPixel_Backend" />
</route>
</router>
</config>
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="weltpixel" translate="label" sortOrder="2000" class="weltpixel-tab">
<label>WeltPixel</label>
</tab>
<section id="weltpixel_backend_developer" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Developer</label>
<tab>weltpixel</tab>
<resource>WeltPixel_Backend::DeveloperSettings</resource>
<group id="system_information" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<label>System Information</label>
<field id="infromation_details" translate="button_label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<frontend_model>WeltPixel\Backend\Block\Adminhtml\System\Config\SystemInformation</frontend_model>
</field>
</group>
<group id="csp" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Content Security Policies</label>
<field id="change_system_value" translate="label comment" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Change Magento Default Mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Only available from 2.3.5 version.</comment>
</field>
<field id="report_only" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Report Only</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="change_system_value">1</field>
</depends>
</field>
</group>
</section>
</system>
</config>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<weltpixel_backend_developer>
<csp>
<change_system_value>0</change_system_value>
<report_only>1</report_only>
</csp>
</weltpixel_backend_developer>
</default>
</config>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="frame-src">
<values>
<value id="weltpixel_documentation" type="host">*.weltpixel.com</value>
</values>
</policy>
</policies>
</csp_whitelist>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="WeltPixel\Backend\Model\ResourceModel\Debugger\Grid\Collection">
<arguments>
<argument name="mainTable" xsi:type="string">weltpixel_debugger</argument>
<argument name="eventPrefix" xsi:type="string">weltpixel_debugger_grid_collection</argument>
<argument name="eventObject" xsi:type="string">weltpixel_debugger_grid_collection</argument>
<argument name="resourceModel" xsi:type="string">Magento\Framework\DataObject </argument>
</arguments>
</type>
</config>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\App\Config\ScopeConfigInterface">
<plugin name="weltpixel-backend-scopeconfig"
type="WeltPixel\Backend\Plugin\ScopeConfig" sortOrder="10"/>
</type>
</config>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="WeltPixel_Backend">
<sequence>
<module name="Magento_AdminNotification"/>
</sequence>
</module>
</config>
+33
View File
@@ -0,0 +1,33 @@
"Only Custom Modules","Only Custom Modules"
"All Magento Modules","All Magento Modules"
OK,OK
"CHECK REWRITE","CHECK REWRITE"
N/A,N/A
"Up to Date","Up to Date"
"Update needed","Update needed"
Modules,Modules
"Check Rewrites / Preferences","Check Rewrites / Preferences"
Valid,Valid
Invalid,Invalid
"Yes (Recommended)","Yes (Recommended)"
No,No
Enabled,Enabled
"Current Version","Current Version"
"Latest Version","Latest Version"
"Theme module","Theme module"
Themes,Themes
WeltPixel,WeltPixel
"WeltPixel Documentation","WeltPixel Documentation"
"Recommended Solutions:","Recommended Solutions:"
Developer,Developer
"System Information","System Information"
Logs,Logs
"Enable broken reference logs","Enable broken reference logs"
"Content Security Policies","Content Security Policies"
"Change Magento Default Mode","Change Magento Default Mode"
"Only available from 2.3.5 version.","Only available from 2.3.5 version."
"Report Only","Report Only"
Area,Area
"Original Class","Original Class"
"Rewrite Class","Rewrite Class"
Status,Status
1 Only Custom Modules Only Custom Modules
2 All Magento Modules All Magento Modules
3 OK OK
4 CHECK REWRITE CHECK REWRITE
5 N/A N/A
6 Up to Date Up to Date
7 Update needed Update needed
8 Modules Modules
9 Check Rewrites / Preferences Check Rewrites / Preferences
10 Valid Valid
11 Invalid Invalid
12 Yes (Recommended) Yes (Recommended)
13 No No
14 Enabled Enabled
15 Current Version Current Version
16 Latest Version Latest Version
17 Theme module Theme module
18 Themes Themes
19 WeltPixel WeltPixel
20 WeltPixel Documentation WeltPixel Documentation
21 Recommended Solutions: Recommended Solutions:
22 Developer Developer
23 System Information System Information
24 Logs Logs
25 Enable broken reference logs Enable broken reference logs
26 Content Security Policies Content Security Policies
27 Change Magento Default Mode Change Magento Default Mode
28 Only available from 2.3.5 version. Only available from 2.3.5 version.
29 Report Only Report Only
30 Area Area
31 Original Class Original Class
32 Rewrite Class Rewrite Class
33 Status Status
+7
View File
@@ -0,0 +1,7 @@
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'WeltPixel_Backend',
__DIR__
);
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="WeltPixel_Backend::jscolor/jscolor.js"/>
</head>
</page>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="before.body.end">
<block class="Magento\Backend\Block\Template" template="WeltPixel_Backend::helpcenter/init.phtml"/>
<block class="Magento\Backend\Block\Template" template="WeltPixel_Backend::menu/adjustments.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<block class="WeltPixel\Backend\Block\Adminhtml\Debugger" name="weltpixel_rewrites_grid">
<block class="Magento\Backend\Block\Widget\Grid" name="weltpixel_rewrites_grid.grid" as="grid">
<arguments>
<argument name="dataSource" xsi:type="object">WeltPixel\Backend\Model\ResourceModel\Debugger\Grid\Collection</argument>
<argument name="pager_visibility" xsi:type="string">0</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\ColumnSet" name="weltpixel_rewrites_grid.grid.columnSet" as="grid.columnSet">
<arguments>
<argument name="filter_visibility" xsi:type="string">1</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="area">
<arguments>
<argument name="header" xsi:type="string" translate="true">Area</argument>
<argument name="index" xsi:type="string">area</argument>
<argument name="sortable" xsi:type="string">0</argument>
<argument name="filter" xsi:type="string">0</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="original_class">
<arguments>
<argument name="header" xsi:type="string" translate="true">Original Class</argument>
<argument name="index" xsi:type="string">original_class</argument>
<argument name="sortable" xsi:type="string">0</argument>
<!--<argument name="filter" xsi:type="string">0</argument>-->
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="rewrite_class">
<arguments>
<argument name="header" xsi:type="string" translate="true">Rewrite Class</argument>
<argument name="index" xsi:type="string">rewrite_class</argument>
<argument name="sortable" xsi:type="string">0</argument>
<argument name="filter" xsi:type="string">0</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="status">
<arguments>
<argument name="header" xsi:type="string" translate="true">Status</argument>
<argument name="filter" xsi:type="string">0</argument>
<argument name="sortable" xsi:type="string">0</argument>
<argument name="renderer" xsi:type="string">WeltPixel\Backend\Block\Adminhtml\Grid\Renderer\RewriteStatus</argument>
<argument name="header_css_class" xsi:type="string">col-rewrite-status</argument>
</arguments>
</block>
</block>
</block>
</block>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,16 @@
<?php
/** @var \WeltPixel\Backend\Helper\Utility $wpHelper */
$wpHelper = $this->helper('WeltPixel\Backend\Helper\Utility');
$cspNonceProvider = $wpHelper->getCspNonceProvider();
?>
<div>
<input type="hidden" name="wp_base_url_jscolor" id="wp_base_url_jscolor" value="<?php /* @noEscape */ echo $this->getViewFileUrl('WeltPixel_Backend::jscolor'); ?>" />
</div>
<script<?php if ($cspNonceProvider): ?> nonce="<?= $block->escapeHtmlAttr($cspNonceProvider->generateNonce()) ?>"<?php endif; ?>>
requirejs(['jquery' ],
function ($) {
$(document).ready(function() {
$('.item-weltpixel-helpcenter a').attr('href', 'https://support.weltpixel.com/hc/en-us').attr('target', '_blank');
});
});
</script>
@@ -0,0 +1,43 @@
<?php
/** @var \WeltPixel\Backend\Helper\Utility $wpHelper */
$wpHelper = $this->helper('WeltPixel\Backend\Helper\Utility');
$cspNonceProvider = $wpHelper->getCspNonceProvider();
?>
<script<?php if ($cspNonceProvider): ?> nonce="<?= $block->escapeHtmlAttr($cspNonceProvider->generateNonce()) ?>"<?php endif; ?>>
requirejs(['jquery' ],
function ($) {
$(document).ready(function() {
var wpSubmenu = $('#menu-weltpixel-backend-weltpixel > .submenu');
function wpAdjustMenuWidth() {
var windowWidth = $(window).width() - 80;
if (wpSubmenu && wpSubmenu.length) {
if (wpSubmenu[0].scrollWidth > windowWidth) {
wpSubmenu.css({
'overflow-x': 'scroll',
'width': windowWidth - 20,
'max-width': windowWidth - 20
});
} else {
wpSubmenu.css({
'overflow-x': 'initial',
'width': 'initial',
'max-width': 'initial'
});
}
}
}
wpAdjustMenuWidth();
$(window).resize(function(){
wpAdjustMenuWidth();
});
$(wpSubmenu).on('scroll', function(event) {
$('.action-close').css('right', ( -1 * wpSubmenu.scrollLeft()) + 'px');
});
});
});
</script>
@@ -0,0 +1,70 @@
<?php
/** @var $block \WeltPixel\Backend\Block\Adminhtml\System\Config\SystemInformation */
/** @var \WeltPixel\Backend\Helper\Developer $developerHelper */
$developerHelper = $this->helper('WeltPixel\Backend\Helper\Developer');
$cronjoblimit = 100;
$scheduleCollection = $developerHelper->getLatestCronJobs($cronjoblimit);
/** @var \WeltPixel\Backend\Helper\Utility $wpHelper */
$wpHelper = $this->helper('WeltPixel\Backend\Helper\Utility');
$cspNonceProvider = $wpHelper->getCspNonceProvider();
?>
<div class="col-xs-12 system-infromation-container">
<div class="col-xs-6 information-label">Magento Mode</div>
<div class="col-xs-6"><?php echo $block->escapeHtml(ucfirst($this->getMagentoMode())); ?></div>
<div class="col-xs-6 information-label">Magento Installation Path</div>
<div class="col-xs-6"><?php echo $block->escapeHtml($this->getMagentoPath()); ?></div>
<div class="col-xs-6 information-label">Magento Edition</div>
<div class="col-xs-6"><?php echo $block->escapeHtml($developerHelper->getMagentoEdition()); ?></div>
<div class="col-xs-6 information-label">PHP Version</div>
<div class="col-xs-6"><?php echo $block->escapeHtml(phpversion()) ?></div>
<div class="col-xs-6 information-label">Server User</div>
<div class="col-xs-6"><?php echo $block->escapeHtml($developerHelper->getCurrentServerUser()); ?></div>
<div class="col-xs-6 information-label">Server User Group</div>
<div class="col-xs-6"><?php echo $block->escapeHtml($developerHelper->getCurrentServerUserGroup()); ?></div>
<div class="col-xs-6 information-label">Current Time</div>
<div class="col-xs-6"><?php echo $block->escapeHtml($developerHelper->getServerTime()); ?></div>
<div class="col-xs-6 information-label">Latest Cron Jobs (<?php echo $block->escapeHtml($cronjoblimit) ?>)</div>
<div class="col-xs-6"></div>
<div class="col-xs-12 cronjob-header">
<table>
<thead>
<tr>
<th class="job-code">Job Code</th>
<th class="status">Status</th>
<th class="created-at">Created At</th>
<th class="scheduled-at">Scheduled At</th>
<th class="executed-at">Executed At</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-xs-12 cronjob-details">
<table>
<tbody>
<?php foreach ($scheduleCollection->getItems() as $item ) : ?>
<tr>
<td class="job-code"><?php /* @noEscape */ echo $item->getJobCode(); ?> </td>
<td class="status"><?php /* @noEscape */ echo $item->getStatus(); ?> </td>
<td class="created-at"><?php /* @noEscape */ echo $item->getCreatedAt(); ?> </td>
<td class="scheduled-at"><?php /* @noEscape */ echo $item->getScheduledAt(); ?> </td>
<td class="executed-at"><?php /* @noEscape */ echo ($item->getExecutedAt()) ? $item->getExecutedAt() : '-' ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<script<?php if ($cspNonceProvider): ?> nonce="<?= $block->escapeHtmlAttr($cspNonceProvider->generateNonce()) ?>"<?php endif; ?>>
requirejs(['jquery'],function($) {
$(document).ready(function() {
$('#row_weltpixel_backend_developer_system_information_infromation_details .label').hide();
$('#row_weltpixel_backend_developer_system_information_infromation_details .value').css('width', '100%');
});
});
</script>
@@ -0,0 +1,4 @@
<div>
<p>1. After changing theme settings make sure to clear related caches: Regenerate Pearl Theme CSS, Flush Magento Cache, Clear Browser Cache (if necessary also Flush JS/CSS Cache, Flush Catalog Images Files, Flush Cache Storage)</p>
<p>2. Make sure you are changing the settings on the right store view, settings may be different in default config vs. storeview</p>
</div>
@@ -0,0 +1,364 @@
@weltpixel_store_color: #FFF;
#nav {
li.item-weltpixel {
> a {
&:before {
content: '';
background-image: url("../WeltPixel_Backend/images/WeltPixel_logo.svg");
background-repeat: no-repeat;
background-size: 70px;
background-position: center;
height: 50px;
}
> span {
font-size: 0px;
}
}
.submenu {
.submenu-title {
background-image: url("../WeltPixel_Backend/images/WeltPixel_logo.svg");
background-repeat: no-repeat;
padding-left: 80px;
height: 80px;
font-size: 0px;
margin-bottom: 15px;
background-size: 120px;
}
.item-weltpixel-documentation {
a {
&:after {
content: '\e60d';
font-family: 'Admin Icons';
margin-left: 10px;
}
}
}
.item-weltpixel-helpcenter {
a {
&:after {
content: '\e633';
font-family: 'Admin Icons';
margin-left: 10px;
vertical-align: baseline;
font-size: 13px;
}
}
}
.item-weltpixel-debugger {
.submenu-group-title {
&:after {
content: '\e613';
font-family: 'Admin Icons';
margin-left: 10px;
color: #FFF;
}
}
}
.item-pearl-theme-options {
display: none;
&.parent {
display: block
}
}
.parent {
margin-bottom: 1em;
.submenu-group-title {
margin-bottom: 0px;
padding: 0.7rem 0.5rem;
}
}
li {
min-width: 20rem;
&.level-1 {
margin-left: 0.5rem;
margin-right: 0.5rem;
a {
padding: 0.5rem 0.5rem;
font-size: 13px;
}
}
}
}
}
}
.config-nav {
.item-weltpixel-documentation {
a {
&:after {
content: '\e60d';
font-family: 'Admin Icons';
margin-left: 10px;
}
}
}
.weltpixel-tab {
.admin__page-nav-title {
strong {margin-left: 50px;}
&:before {
content: '';
background-image: url("../WeltPixel_Backend/images/WeltPixel_logo_dark.svg");
background-repeat: no-repeat;
background-size: 40px;
background-position: 0px 0px;
height: 30px;
position: absolute;
width: 50px;
top: 14px;
}
}
}
}
#weltpixel_store {
border: none;
height: 1500px;
}
.section-config {
&.weltpixel-recommended-header {
.admin__collapsible-block {
display: block !important;
a {
font-weight: normal;
text-transform: uppercase;
&:before {
content: '' !important;
}
}
table {
td.label {
display: none;
}
td.value {
width: 100%;
}
}
}
}
}
iframe#launcher {
display: none !important;
}
.col-rewrite-status {width: 160px;}
.rewrite-status, .license-status {
width: 100%;
display: block;
text-align: center;
padding: 5px;
font-weight: bold;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
color: #FFF;
}
.rewrite-status-nok, .license-status-nok {
background-color: #ff0000;
}
.rewrite-status-ok, .license-status-ok {
background-color: #00aa00;
}
.module-title {
font-size: 16px;
}
.module-theme-info {
font-size: 12px;
font-style: italic;
font-weight: bold;
}
.license-container {
.admin__table-secondary {
background-color: #FFF;
tbody tr td {
background-color: #FFF;
}
}
.admin_table_filled {
background-color: #f1f1f1;
tbody tr td {
background-color: #f1f1f1;
}
}
th {
&.license-name {
width: 24%;
}
&.license-key {
width: 68%;
}
&.license-validity {
width: 8%;
}
}
td {
&.license-name {
width: 24%;
font-size: 16px;
}
&.license-key {
width: 68%;
word-break: break-all;
}
&.license-validity {
width: 8%;
}
}
.license-input {
width: 85%;
margin-right: 20px;
}
}
.system-infromation-container {
div {
margin: 5px 0;
}
.information-label {
text-align: right;
font-weight: bold;
padding-right: 2%;
width: 47%;
}
.cronjob-header {
padding: 10px;
border: 1px solid;
border-bottom: none;
margin: 0;
margin-top: 20px;
table {
th, td {
text-align: right;
}
th {
&.job-code {
width: 43%;
}
&.status {
width: 8%;
}
&.created-at {
width: 16%;
}
&.scheduled-at {
width: 16%;
}
&.executed-at {
width: 17%;
}
}
}
}
.cronjob-details {
margin-top: 0px;
border: 1px solid;
padding: 10px;
height: 300px;
overflow-y: scroll;
table {
th, td {
text-align: right;
}
td {
&.job-code {
width: 43%;
}
&.status {
width: 8%;
}
&.created-at {
width: 16%;
}
&.scheduled-at {
width: 16%;
}
&.executed-at {
width: 17%;
}
}
}
}
}
.license-pmsg {
padding: 20px 10px;
font-weight:700;
color: #fff;
letter-spacing:1px;
&.invalid-license-pmsg {
background: #f30d49;
}
&.valid-license-pmsg {
background: #359639;
}
}
.tfa-google-auth {
.message-error {
display: none;
}
}
.section-config.weltpixel-module-information-header {
.admin__collapsible-block {
display: block !important;
a {
font-weight: normal;
text-transform: initial;
&:before {
content: '' !important;
}
}
table {
td.label {
display: none;
}
td.value {
padding-top: 0;
width: 100%;
}
}
.wp-module-version {
color: #1c8ecb;
font-weight: 600;
}
.message {
width: fit-content;
p {
margin: 0;
}
}
strong {
&.old-version {
color: red;
}
&.current-version {
color: green;
}
}
.request-feature-button {
padding: 20px 0 0 0;
#request_feature {
background-color: #073756;
border: #fff;
padding: 10px 15px;
color: #FFF;
font-weight: 600;
&:hover {
background-color: #2f5e7d;
box-shadow: 0 0 10px #073756;
}
}
}
}
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="69px" height="42px" viewBox="0 0 69 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41 (35326) - http://www.bohemiancoding.com/sketch -->
<title>logo_white</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="weltpixel_homepage-2" transform="translate(-80.000000, -14.000000)" fill="#FFFFFF">
<g id="1_header">
<g id="menu">
<g id="logo_white" transform="translate(80.000000, 14.000000)">
<path d="M68.3067033,29.10096 C67.5730033,29.2078691 66.9842033,29.2613236 66.5334033,29.2613236 C65.9369367,29.2613236 65.47847,29.1628145 65.1580033,28.9719055 C64.83677,28.7741236 64.6083033,28.5144873 64.4626367,28.1876509 C64.3254033,27.8608145 64.2564033,27.1300145 64.2564033,25.9807418 L64.2564033,12.1337236 L68.3067033,12.1337236 L68.3067033,9.01274182 L64.2564033,9.01274182 L64.2564033,0.737978182 L60.2429033,3.14419636 L60.2429033,9.01274182 L57.2866367,9.01274182 L57.2866367,12.1337236 L60.2429033,12.1337236 L60.2429033,25.7592873 C60.2429033,28.1647418 60.4123367,29.74776 60.74047,30.4945964 C61.06937,31.2483055 61.63517,31.8569236 62.4371033,32.3135782 C63.2467033,32.7786327 64.3783033,33.0061964 65.8449367,33.0061964 C66.7396367,33.0061964 67.7562367,32.8847782 68.88707,32.6480509 L68.3067033,29.10096 Z M53.2923033,32.6946327 L57.3196033,32.6946327 L57.3196033,0.000305454545 L53.2923033,0.000305454545 L53.2923033,32.6946327 Z M34.9835367,18.5734691 C35.1215367,16.5108873 35.81767,14.8591418 37.0788367,13.6251055 C38.3392367,12.3925964 39.89787,11.7763418 41.74707,11.7763418 C43.7879367,11.7763418 45.4531367,12.5521964 46.73807,14.09856 C47.57067,15.0867055 48.0828033,16.5872509 48.2591367,18.5734691 L34.9835367,18.5734691 Z M48.2131367,25.0666691 C47.6013367,26.7642327 46.7764033,27.9975055 45.7299033,28.7664873 C44.6826367,29.5431055 43.4207033,29.9310327 41.9464033,29.9310327 C39.9584367,29.9310327 38.30857,29.2384145 36.97917,27.8531782 C35.6482367,26.4755782 34.9076367,24.48096 34.7627367,21.8777236 L52.49267,21.8777236 C52.5080033,21.4050327 52.5149033,21.0476509 52.5149033,20.8040509 C52.5149033,16.8988145 51.5067367,13.8618327 49.4896367,11.7076145 C47.4794367,9.55339636 44.87967,8.47285091 41.7018367,8.47285091 C38.4159033,8.47285091 35.74867,9.57630545 33.6848033,11.7763418 C31.6286033,13.9756145 30.5974367,17.0660509 30.5974367,21.0552873 C30.5974367,24.9070691 31.61327,27.8989964 33.65337,30.0295418 C35.68657,32.1616145 38.44657,33.2268873 41.9234033,33.2268873 C44.6826367,33.2268873 46.9512033,32.5571782 48.73217,31.2253964 C50.50547,29.8852145 51.71987,28.0043782 52.3784367,25.5767782 L48.2131367,25.0666691 Z M7.27543667,32.6946327 L-0.00023,9.01274182 L4.16583667,9.01274182 L7.94780333,22.6848873 L9.35463667,27.7691782 C9.41597,27.5103055 9.82843667,25.8814691 10.58437,22.8819055 L14.36787,9.01274182 L18.51017,9.01274182 L22.07057,22.7452145 L23.2627367,27.2743418 L24.62357,22.6993964 L28.69687,9.01274182 L32.6176033,9.01274182 L25.1817033,32.6946327 L21.00107,32.6946327 L17.2183367,18.5123782 L16.29297,14.4704509 L11.4867367,32.6946327 L7.27543667,32.6946327 Z" id="Fill-1"></path>
<path d="M8.43854667,39.2631273 C8.55431333,39.2852727 8.65704667,39.3013091 8.74674667,39.312 C8.83721333,39.3234545 8.91311333,39.3288 8.97674667,39.3288 C9.20444667,39.3288 9.40071333,39.2409818 9.56631333,39.0661091 C9.73114667,38.8904727 9.81241333,38.6636727 9.81241333,38.3849455 C9.81241333,38.1925091 9.77408,38.0145818 9.69511333,37.8504 C9.61614667,37.6854545 9.50421333,37.5625091 9.36008,37.4808 C9.21594667,37.3990909 9.05188,37.3578545 8.86864667,37.3578545 C8.75671333,37.3578545 8.61334667,37.3792364 8.43854667,37.4204727 L8.43854667,39.2631273 Z M8.43854667,39.4494545 L8.43854667,40.7407636 C8.43854667,41.0187273 8.46921333,41.1920727 8.52978,41.2600364 C8.61334667,41.3554909 8.73984667,41.4036 8.90774667,41.4036 L9.07794667,41.4036 L9.07794667,41.5242545 L7.17201333,41.5242545 L7.17201333,41.4036 L7.33991333,41.4036 C7.52774667,41.4036 7.66191333,41.3425091 7.74241333,41.2203273 C7.78688,41.1531273 7.80911333,40.9935273 7.80911333,40.7407636 L7.80911333,37.8778909 C7.80911333,37.5991636 7.77921333,37.4258182 7.72018,37.3578545 C7.63508,37.2624 7.50781333,37.2142909 7.33991333,37.2142909 L7.17201333,37.2142909 L7.17201333,37.0936364 L8.80348,37.0936364 C9.20061333,37.0936364 9.51418,37.1341091 9.74418,37.2158182 C9.97418,37.2982909 10.16738,37.4349818 10.3253133,37.6297091 C10.48248,37.8236727 10.5614467,38.0527636 10.5614467,38.3192727 C10.5614467,38.6797091 10.4418467,38.9744727 10.20188,39.2012727 C9.96268,39.4280727 9.62381333,39.5410909 9.18681333,39.5410909 C9.08024667,39.5410909 8.96371333,39.5334545 8.83798,39.5181818 C8.71378,39.5029091 8.58114667,39.48 8.43854667,39.4494545 L8.43854667,39.4494545 Z" id="Fill-4"></path>
<path d="M23.4870633,41.4034473 L23.4870633,41.5241018 L21.58113,41.5241018 L21.58113,41.4034473 L21.73753,41.4034473 C21.92153,41.4034473 22.0556967,41.3499927 22.1392633,41.2438473 C22.19063,41.1735927 22.2166967,41.0063564 22.2166967,40.7406109 L22.2166967,37.8777382 C22.2166967,37.6539927 22.2036633,37.5058473 22.17453,37.4333018 C22.1522967,37.3790836 22.10783,37.3317382 22.0395967,37.2927927 C21.9437633,37.2408655 21.84333,37.2149018 21.73753,37.2149018 L21.58113,37.2149018 L21.58113,37.0934836 L23.4870633,37.0934836 L23.4870633,37.2149018 L23.3260633,37.2149018 C23.14513,37.2149018 23.0124967,37.2675927 22.92893,37.3745018 C22.8744967,37.4439927 22.8468967,37.6119927 22.8468967,37.8777382 L22.8468967,40.7406109 C22.8468967,40.96512 22.8614633,41.1125018 22.88983,41.1850473 C22.9112967,41.2392655 22.9580633,41.2858473 23.02783,41.3255564 C23.1213633,41.3782473 23.22103,41.4034473 23.3260633,41.4034473 L23.4870633,41.4034473 Z" id="Fill-6"></path>
<path d="M37.0096067,39.0707673 L37.9648733,40.48884 C38.2286067,40.8805855 38.42564,41.1287673 38.5536733,41.2318582 C38.6817067,41.3364764 38.84424,41.3929855 39.0412733,41.4036764 L39.0412733,41.5243309 L37.13074,41.5243309 L37.13074,41.4036764 C37.2580067,41.4021491 37.35154,41.3884036 37.4128733,41.3647309 C37.45964,41.34564 37.49644,41.3150945 37.52634,41.2753855 C37.5554733,41.2349127 37.5715733,41.1929127 37.5715733,41.1516764 C37.5715733,41.10204 37.56084,41.0524036 37.5409067,41.0020036 C37.5255733,40.9645855 37.4657733,40.8691309 37.36074,40.7141127 L36.60634,39.5762945 L35.6740733,40.7668036 C35.57594,40.8935673 35.5176733,40.9775673 35.4969733,41.0203309 C35.47704,41.0615673 35.46784,41.1066218 35.46784,41.1516764 C35.46784,41.2211673 35.4969733,41.2799673 35.5567733,41.3257855 C35.61504,41.37084 35.72774,41.3975673 35.8948733,41.4036764 L35.8948733,41.5243309 L34.3163067,41.5243309 L34.3163067,41.4036764 C34.4274733,41.3929855 34.5233067,41.37084 34.6045733,41.3349491 C34.74104,41.27844 34.86984,41.2020764 34.99174,41.1066218 C35.1144067,41.0104036 35.25394,40.8637855 35.4118733,40.66524 L36.46144,39.3449127 L35.5866733,38.0673491 C35.3474733,37.7206582 35.1450733,37.4946218 34.9794733,37.3861855 C34.81234,37.2777491 34.6206733,37.22124 34.40524,37.2143673 L34.40524,37.0937127 L36.46144,37.0937127 L36.46144,37.2143673 C36.28664,37.22124 36.1662733,37.2494945 36.10264,37.2991309 C36.03824,37.3495309 36.0068067,37.4052764 36.0068067,37.4656036 C36.0068067,37.5465491 36.0581733,37.6641491 36.1632067,37.8191673 L36.8447733,38.8348036 L37.6359733,37.8390218 C37.7279733,37.7206582 37.7847067,37.6404764 37.80464,37.5969491 C37.8261067,37.5534218 37.83684,37.5083673 37.83684,37.4633127 C37.83684,37.4167309 37.8238067,37.3762582 37.7969733,37.3418945 C37.7640067,37.2960764 37.7226067,37.2640036 37.6727733,37.2456764 C37.6221733,37.2265855 37.5186733,37.2166582 37.36074,37.2143673 L37.36074,37.0937127 L38.9393067,37.0937127 L38.9393067,37.2143673 C38.81434,37.22124 38.7123733,37.2410945 38.6334067,37.2731673 C38.51534,37.3235673 38.40724,37.3907673 38.30834,37.4762945 C38.2109733,37.5610582 38.0722067,37.7183673 37.89204,37.9459309 L37.0096067,39.0707673 Z" id="Fill-8"></path>
<path d="M51.1390433,37.3354036 L51.1390433,39.0871855 L52.1165433,39.0871855 C52.3710767,39.0871855 52.5397433,39.04824 52.62561,38.97264 C52.7390767,38.8726036 52.80271,38.6962036 52.8157433,38.4426764 L52.9368767,38.4426764 L52.9368767,39.9852218 L52.8157433,39.9852218 C52.78431,39.7698764 52.75441,39.6316582 52.7237433,39.5705673 C52.68541,39.4942036 52.6194767,39.43464 52.53131,39.3903491 C52.4408433,39.3475855 52.3028433,39.32544 52.1165433,39.32544 L51.1390433,39.32544 L51.1390433,40.7862764 C51.1390433,40.9817673 51.1482433,41.1024218 51.16511,41.1436582 C51.1827433,41.1871855 51.21341,41.2207855 51.2563433,41.2452218 C51.3015767,41.2704218 51.38361,41.28264 51.5070433,41.28264 L52.2614433,41.28264 C52.5121433,41.28264 52.6953767,41.2650764 52.80961,41.2307127 C52.92231,41.1963491 53.03271,41.1276218 53.1377433,41.0245309 C53.2726767,40.8886036 53.4114433,40.68624 53.5540433,40.4128582 L53.6851433,40.4128582 L53.3002767,41.5239491 L49.87251,41.5239491 L49.87251,41.4032945 L50.0304433,41.4032945 C50.1354767,41.4032945 50.2343767,41.3788582 50.3286767,41.3284582 C50.3984433,41.2940945 50.4467433,41.24064 50.4712767,41.1719127 C50.4965767,41.1024218 50.50961,40.9588582 50.50961,40.7435127 L50.50961,37.86384 C50.50961,37.5835855 50.4812433,37.41024 50.4237433,37.3453309 C50.3455433,37.2575127 50.2136767,37.2147491 50.0304433,37.2147491 L49.87251,37.2147491 L49.87251,37.0933309 L53.3002767,37.0933309 L53.3508767,38.0639127 L53.2228433,38.0639127 C53.1760767,37.8310036 53.1254767,37.6698764 53.06951,37.5835855 C53.0135433,37.4965309 52.93151,37.4300945 52.82111,37.3842764 C52.7344767,37.35144 52.5803767,37.3354036 52.3603433,37.3354036 L51.1390433,37.3354036 Z" id="Fill-11"></path>
<path d="M68.3067033,40.2997636 L68.4148033,40.3219091 L68.0345367,41.5246364 L64.5891367,41.5246364 L64.5891367,41.4032182 L64.75627,41.4032182 C64.9441033,41.4032182 65.0798033,41.3421273 65.1603033,41.2207091 C65.2063033,41.1512182 65.2293033,40.9893273 65.2293033,40.7365636 L65.2293033,37.8775091 C65.2293033,37.6010727 65.1986367,37.4284909 65.1373033,37.3582364 C65.0522033,37.2620182 64.9257033,37.2146727 64.75627,37.2146727 L64.5891367,37.2146727 L64.5891367,37.0932545 L66.60317,37.0932545 L66.60317,37.2146727 C66.3678033,37.2116182 66.2022033,37.2337636 66.10637,37.2795818 C66.0113033,37.3254 65.9469033,37.3834364 65.9116367,37.4529273 C65.87637,37.5224182 65.8595033,37.6896545 65.8595033,37.9538727 L65.8595033,40.7365636 C65.8595033,40.9175455 65.87637,41.0427818 65.9116367,41.1099818 C65.9377033,41.1558 65.9791033,41.1886364 66.03277,41.2107818 C66.0872033,41.2329273 66.25817,41.2436182 66.5449033,41.2436182 L66.8692033,41.2436182 C67.21037,41.2436182 67.4503367,41.2184182 67.5883367,41.1687818 C67.72557,41.1183818 67.85207,41.0298 67.9655367,40.9022727 C68.0790033,40.7755091 68.1932367,40.5731455 68.3067033,40.2997636" id="Fill-13"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="69px" height="42px" viewBox="0 0 69 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41 (35326) - http://www.bohemiancoding.com/sketch -->
<title>logo_white</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="weltpixel_homepage-2" transform="translate(-80.000000, -14.000000)" fill="#000000">
<g id="1_header">
<g id="menu">
<g id="logo_white" transform="translate(80.000000, 14.000000)">
<path d="M68.3067033,29.10096 C67.5730033,29.2078691 66.9842033,29.2613236 66.5334033,29.2613236 C65.9369367,29.2613236 65.47847,29.1628145 65.1580033,28.9719055 C64.83677,28.7741236 64.6083033,28.5144873 64.4626367,28.1876509 C64.3254033,27.8608145 64.2564033,27.1300145 64.2564033,25.9807418 L64.2564033,12.1337236 L68.3067033,12.1337236 L68.3067033,9.01274182 L64.2564033,9.01274182 L64.2564033,0.737978182 L60.2429033,3.14419636 L60.2429033,9.01274182 L57.2866367,9.01274182 L57.2866367,12.1337236 L60.2429033,12.1337236 L60.2429033,25.7592873 C60.2429033,28.1647418 60.4123367,29.74776 60.74047,30.4945964 C61.06937,31.2483055 61.63517,31.8569236 62.4371033,32.3135782 C63.2467033,32.7786327 64.3783033,33.0061964 65.8449367,33.0061964 C66.7396367,33.0061964 67.7562367,32.8847782 68.88707,32.6480509 L68.3067033,29.10096 Z M53.2923033,32.6946327 L57.3196033,32.6946327 L57.3196033,0.000305454545 L53.2923033,0.000305454545 L53.2923033,32.6946327 Z M34.9835367,18.5734691 C35.1215367,16.5108873 35.81767,14.8591418 37.0788367,13.6251055 C38.3392367,12.3925964 39.89787,11.7763418 41.74707,11.7763418 C43.7879367,11.7763418 45.4531367,12.5521964 46.73807,14.09856 C47.57067,15.0867055 48.0828033,16.5872509 48.2591367,18.5734691 L34.9835367,18.5734691 Z M48.2131367,25.0666691 C47.6013367,26.7642327 46.7764033,27.9975055 45.7299033,28.7664873 C44.6826367,29.5431055 43.4207033,29.9310327 41.9464033,29.9310327 C39.9584367,29.9310327 38.30857,29.2384145 36.97917,27.8531782 C35.6482367,26.4755782 34.9076367,24.48096 34.7627367,21.8777236 L52.49267,21.8777236 C52.5080033,21.4050327 52.5149033,21.0476509 52.5149033,20.8040509 C52.5149033,16.8988145 51.5067367,13.8618327 49.4896367,11.7076145 C47.4794367,9.55339636 44.87967,8.47285091 41.7018367,8.47285091 C38.4159033,8.47285091 35.74867,9.57630545 33.6848033,11.7763418 C31.6286033,13.9756145 30.5974367,17.0660509 30.5974367,21.0552873 C30.5974367,24.9070691 31.61327,27.8989964 33.65337,30.0295418 C35.68657,32.1616145 38.44657,33.2268873 41.9234033,33.2268873 C44.6826367,33.2268873 46.9512033,32.5571782 48.73217,31.2253964 C50.50547,29.8852145 51.71987,28.0043782 52.3784367,25.5767782 L48.2131367,25.0666691 Z M7.27543667,32.6946327 L-0.00023,9.01274182 L4.16583667,9.01274182 L7.94780333,22.6848873 L9.35463667,27.7691782 C9.41597,27.5103055 9.82843667,25.8814691 10.58437,22.8819055 L14.36787,9.01274182 L18.51017,9.01274182 L22.07057,22.7452145 L23.2627367,27.2743418 L24.62357,22.6993964 L28.69687,9.01274182 L32.6176033,9.01274182 L25.1817033,32.6946327 L21.00107,32.6946327 L17.2183367,18.5123782 L16.29297,14.4704509 L11.4867367,32.6946327 L7.27543667,32.6946327 Z" id="Fill-1"></path>
<path d="M8.43854667,39.2631273 C8.55431333,39.2852727 8.65704667,39.3013091 8.74674667,39.312 C8.83721333,39.3234545 8.91311333,39.3288 8.97674667,39.3288 C9.20444667,39.3288 9.40071333,39.2409818 9.56631333,39.0661091 C9.73114667,38.8904727 9.81241333,38.6636727 9.81241333,38.3849455 C9.81241333,38.1925091 9.77408,38.0145818 9.69511333,37.8504 C9.61614667,37.6854545 9.50421333,37.5625091 9.36008,37.4808 C9.21594667,37.3990909 9.05188,37.3578545 8.86864667,37.3578545 C8.75671333,37.3578545 8.61334667,37.3792364 8.43854667,37.4204727 L8.43854667,39.2631273 Z M8.43854667,39.4494545 L8.43854667,40.7407636 C8.43854667,41.0187273 8.46921333,41.1920727 8.52978,41.2600364 C8.61334667,41.3554909 8.73984667,41.4036 8.90774667,41.4036 L9.07794667,41.4036 L9.07794667,41.5242545 L7.17201333,41.5242545 L7.17201333,41.4036 L7.33991333,41.4036 C7.52774667,41.4036 7.66191333,41.3425091 7.74241333,41.2203273 C7.78688,41.1531273 7.80911333,40.9935273 7.80911333,40.7407636 L7.80911333,37.8778909 C7.80911333,37.5991636 7.77921333,37.4258182 7.72018,37.3578545 C7.63508,37.2624 7.50781333,37.2142909 7.33991333,37.2142909 L7.17201333,37.2142909 L7.17201333,37.0936364 L8.80348,37.0936364 C9.20061333,37.0936364 9.51418,37.1341091 9.74418,37.2158182 C9.97418,37.2982909 10.16738,37.4349818 10.3253133,37.6297091 C10.48248,37.8236727 10.5614467,38.0527636 10.5614467,38.3192727 C10.5614467,38.6797091 10.4418467,38.9744727 10.20188,39.2012727 C9.96268,39.4280727 9.62381333,39.5410909 9.18681333,39.5410909 C9.08024667,39.5410909 8.96371333,39.5334545 8.83798,39.5181818 C8.71378,39.5029091 8.58114667,39.48 8.43854667,39.4494545 L8.43854667,39.4494545 Z" id="Fill-4"></path>
<path d="M23.4870633,41.4034473 L23.4870633,41.5241018 L21.58113,41.5241018 L21.58113,41.4034473 L21.73753,41.4034473 C21.92153,41.4034473 22.0556967,41.3499927 22.1392633,41.2438473 C22.19063,41.1735927 22.2166967,41.0063564 22.2166967,40.7406109 L22.2166967,37.8777382 C22.2166967,37.6539927 22.2036633,37.5058473 22.17453,37.4333018 C22.1522967,37.3790836 22.10783,37.3317382 22.0395967,37.2927927 C21.9437633,37.2408655 21.84333,37.2149018 21.73753,37.2149018 L21.58113,37.2149018 L21.58113,37.0934836 L23.4870633,37.0934836 L23.4870633,37.2149018 L23.3260633,37.2149018 C23.14513,37.2149018 23.0124967,37.2675927 22.92893,37.3745018 C22.8744967,37.4439927 22.8468967,37.6119927 22.8468967,37.8777382 L22.8468967,40.7406109 C22.8468967,40.96512 22.8614633,41.1125018 22.88983,41.1850473 C22.9112967,41.2392655 22.9580633,41.2858473 23.02783,41.3255564 C23.1213633,41.3782473 23.22103,41.4034473 23.3260633,41.4034473 L23.4870633,41.4034473 Z" id="Fill-6"></path>
<path d="M37.0096067,39.0707673 L37.9648733,40.48884 C38.2286067,40.8805855 38.42564,41.1287673 38.5536733,41.2318582 C38.6817067,41.3364764 38.84424,41.3929855 39.0412733,41.4036764 L39.0412733,41.5243309 L37.13074,41.5243309 L37.13074,41.4036764 C37.2580067,41.4021491 37.35154,41.3884036 37.4128733,41.3647309 C37.45964,41.34564 37.49644,41.3150945 37.52634,41.2753855 C37.5554733,41.2349127 37.5715733,41.1929127 37.5715733,41.1516764 C37.5715733,41.10204 37.56084,41.0524036 37.5409067,41.0020036 C37.5255733,40.9645855 37.4657733,40.8691309 37.36074,40.7141127 L36.60634,39.5762945 L35.6740733,40.7668036 C35.57594,40.8935673 35.5176733,40.9775673 35.4969733,41.0203309 C35.47704,41.0615673 35.46784,41.1066218 35.46784,41.1516764 C35.46784,41.2211673 35.4969733,41.2799673 35.5567733,41.3257855 C35.61504,41.37084 35.72774,41.3975673 35.8948733,41.4036764 L35.8948733,41.5243309 L34.3163067,41.5243309 L34.3163067,41.4036764 C34.4274733,41.3929855 34.5233067,41.37084 34.6045733,41.3349491 C34.74104,41.27844 34.86984,41.2020764 34.99174,41.1066218 C35.1144067,41.0104036 35.25394,40.8637855 35.4118733,40.66524 L36.46144,39.3449127 L35.5866733,38.0673491 C35.3474733,37.7206582 35.1450733,37.4946218 34.9794733,37.3861855 C34.81234,37.2777491 34.6206733,37.22124 34.40524,37.2143673 L34.40524,37.0937127 L36.46144,37.0937127 L36.46144,37.2143673 C36.28664,37.22124 36.1662733,37.2494945 36.10264,37.2991309 C36.03824,37.3495309 36.0068067,37.4052764 36.0068067,37.4656036 C36.0068067,37.5465491 36.0581733,37.6641491 36.1632067,37.8191673 L36.8447733,38.8348036 L37.6359733,37.8390218 C37.7279733,37.7206582 37.7847067,37.6404764 37.80464,37.5969491 C37.8261067,37.5534218 37.83684,37.5083673 37.83684,37.4633127 C37.83684,37.4167309 37.8238067,37.3762582 37.7969733,37.3418945 C37.7640067,37.2960764 37.7226067,37.2640036 37.6727733,37.2456764 C37.6221733,37.2265855 37.5186733,37.2166582 37.36074,37.2143673 L37.36074,37.0937127 L38.9393067,37.0937127 L38.9393067,37.2143673 C38.81434,37.22124 38.7123733,37.2410945 38.6334067,37.2731673 C38.51534,37.3235673 38.40724,37.3907673 38.30834,37.4762945 C38.2109733,37.5610582 38.0722067,37.7183673 37.89204,37.9459309 L37.0096067,39.0707673 Z" id="Fill-8"></path>
<path d="M51.1390433,37.3354036 L51.1390433,39.0871855 L52.1165433,39.0871855 C52.3710767,39.0871855 52.5397433,39.04824 52.62561,38.97264 C52.7390767,38.8726036 52.80271,38.6962036 52.8157433,38.4426764 L52.9368767,38.4426764 L52.9368767,39.9852218 L52.8157433,39.9852218 C52.78431,39.7698764 52.75441,39.6316582 52.7237433,39.5705673 C52.68541,39.4942036 52.6194767,39.43464 52.53131,39.3903491 C52.4408433,39.3475855 52.3028433,39.32544 52.1165433,39.32544 L51.1390433,39.32544 L51.1390433,40.7862764 C51.1390433,40.9817673 51.1482433,41.1024218 51.16511,41.1436582 C51.1827433,41.1871855 51.21341,41.2207855 51.2563433,41.2452218 C51.3015767,41.2704218 51.38361,41.28264 51.5070433,41.28264 L52.2614433,41.28264 C52.5121433,41.28264 52.6953767,41.2650764 52.80961,41.2307127 C52.92231,41.1963491 53.03271,41.1276218 53.1377433,41.0245309 C53.2726767,40.8886036 53.4114433,40.68624 53.5540433,40.4128582 L53.6851433,40.4128582 L53.3002767,41.5239491 L49.87251,41.5239491 L49.87251,41.4032945 L50.0304433,41.4032945 C50.1354767,41.4032945 50.2343767,41.3788582 50.3286767,41.3284582 C50.3984433,41.2940945 50.4467433,41.24064 50.4712767,41.1719127 C50.4965767,41.1024218 50.50961,40.9588582 50.50961,40.7435127 L50.50961,37.86384 C50.50961,37.5835855 50.4812433,37.41024 50.4237433,37.3453309 C50.3455433,37.2575127 50.2136767,37.2147491 50.0304433,37.2147491 L49.87251,37.2147491 L49.87251,37.0933309 L53.3002767,37.0933309 L53.3508767,38.0639127 L53.2228433,38.0639127 C53.1760767,37.8310036 53.1254767,37.6698764 53.06951,37.5835855 C53.0135433,37.4965309 52.93151,37.4300945 52.82111,37.3842764 C52.7344767,37.35144 52.5803767,37.3354036 52.3603433,37.3354036 L51.1390433,37.3354036 Z" id="Fill-11"></path>
<path d="M68.3067033,40.2997636 L68.4148033,40.3219091 L68.0345367,41.5246364 L64.5891367,41.5246364 L64.5891367,41.4032182 L64.75627,41.4032182 C64.9441033,41.4032182 65.0798033,41.3421273 65.1603033,41.2207091 C65.2063033,41.1512182 65.2293033,40.9893273 65.2293033,40.7365636 L65.2293033,37.8775091 C65.2293033,37.6010727 65.1986367,37.4284909 65.1373033,37.3582364 C65.0522033,37.2620182 64.9257033,37.2146727 64.75627,37.2146727 L64.5891367,37.2146727 L64.5891367,37.0932545 L66.60317,37.0932545 L66.60317,37.2146727 C66.3678033,37.2116182 66.2022033,37.2337636 66.10637,37.2795818 C66.0113033,37.3254 65.9469033,37.3834364 65.9116367,37.4529273 C65.87637,37.5224182 65.8595033,37.6896545 65.8595033,37.9538727 L65.8595033,40.7365636 C65.8595033,40.9175455 65.87637,41.0427818 65.9116367,41.1099818 C65.9377033,41.1558 65.9791033,41.1886364 66.03277,41.2107818 C66.0872033,41.2329273 66.25817,41.2436182 66.5449033,41.2436182 L66.8692033,41.2436182 C67.21037,41.2436182 67.4503367,41.2184182 67.5883367,41.1687818 C67.72557,41.1183818 67.85207,41.0298 67.9655367,40.9022727 C68.0790033,40.7755091 68.1932367,40.5731455 68.3067033,40.2997636" id="Fill-13"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,91 @@
<?php
namespace WeltPixel\LayeredNavigation\Block\Adminhtml\Product\Attribute\Edit\Tab;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Catalog\Model\Entity\Attribute;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Registry;
/**
* @api
* @since 100.0.2
*/
class Options extends Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
/**
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
FormFactory $formFactory,
array $data = []
) {
parent::__construct($context, $registry, $formFactory, $data);
}
/**
* Return Tab label
*
* @return string
* @api
*/
public function getTabLabel() {
return __('WeltPixel Layered Navigation Properties');
}
/**
* Return Tab title
*
* @return string
* @api
*/
public function getTabTitle() {
return __('WeltPixel Layered Navigation Properties');
}
/**
* Can show tab in tabs
*
* @return boolean
* @api
*/
public function canShowTab() {
return true;
}
/**
* Tab is hidden
*
* @return boolean
* @api
*/
public function isHidden() {
return false;
}
/**
* {@inheritdoc}
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
/** @var Attribute $attributeObject */
$attributeObject = $this->_coreRegistry->registry('entity_attribute');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
$this->_eventManager->dispatch('product_attribute_form_build_weltpixel_layerednavigation_tab', ['form' => $form]);
$this->setForm($form);
$form->setValues($attributeObject->getData());
return parent::_prepareForm();
}
}
@@ -0,0 +1,30 @@
<?php
namespace WeltPixel\LayeredNavigation\Block\Adminhtml\System\Config;
/**
* Implement
* @category WeltPixel_OwlCarouselSlider
* @package WeltPixel_OwlCarouselSlider
* @module OwlCarouselSlider
* @author WeltPixel_OwlCarouselSlider Developer
*/
class InfoMessage extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$number = (int)substr($element->getId(), -1);
$html = '
<div class="message" style="text-align: center; margin-top: 20px;">
<p>' . __('For more settings on attribute level, go to
<strong>Stores -> Attributes -> Product -> [select desired attribute from grid] ->
Storefront Properties -> WeltPixel Layered Navigation Properties</strong>
section.') . '</p>
</div>
';
return $html;
}
}
@@ -0,0 +1,85 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block\LayeredNavigation;
use Magento\Eav\Model\Entity\Attribute;
use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory;
use Magento\Framework\View\Element\Template;
/**
* Class RenderLayered
* @package WeltPixel\LayeredNavigation\Block\LayeredNavigation
*/
class RenderLayered extends \Magento\Swatches\Block\LayeredNavigation\RenderLayered
{
/**
* Path to template file.
*
* @var string
*/
protected $_template = 'WeltPixel_LayeredNavigation::product/layered/renderer.phtml';
/**
* @var \WeltPixel\LayeredNavigation\Model\AttributeOptions
*/
protected $_attributeOptions;
/**
* RenderLayered constructor.
* @param Template\Context $context
* @param Attribute $eavAttribute
* @param AttributeFactory $layerAttribute
* @param \Magento\Swatches\Helper\Data $swatchHelper
* @param \Magento\Swatches\Helper\Media $mediaHelper
* @param \WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
Attribute $eavAttribute,
AttributeFactory $layerAttribute,
\Magento\Swatches\Helper\Data $swatchHelper,
\Magento\Swatches\Helper\Media $mediaHelper,
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions,
array $data = []
) {
$this->eavAttribute = $eavAttribute;
$this->layerAttribute = $layerAttribute;
$this->swatchHelper = $swatchHelper;
$this->mediaHelper = $mediaHelper;
$this->_attributeOptions = $attributeOptions;
parent::__construct($context,$eavAttribute,$layerAttribute,$swatchHelper,$mediaHelper, $data);
}
/**
* return the 'Is Multiselect' attribute configuration value
*
* @return mixed
*/
public function getIsMultiSelect($attrId)
{
return ($attrId > 0) ? $this->getWpAttributeOptions($attrId)->getIsMultiselect() : 0;
}
/**
* Return wp attribute options
*
* @param $attributeId
* @return mixed
*/
public function getWpAttributeOptions($attrId)
{
$this->_attributeOptionsObj = ($attrId > 0) ? $this->_attributeOptions->getDisplayOptionsByAttribute($attrId) : '';
return $this->_attributeOptionsObj;
}
}
@@ -0,0 +1,56 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block;
use Magento\Framework\View\Element\Template\Context;
use WeltPixel\LayeredNavigation\Helper\Data;
class LayeredNavigationAdd extends \Magento\Framework\View\Element\Template
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* @var Data
*/
protected $_wpHelper;
/**
* AjaxInfiniteScroll constructor.
* @param Context $context
* @param Data $helper
* @param array $data
*/
public function __construct(
Context $context,
Data $helper,
array $data = []
) {
$this->_scopeConfig = $context->getScopeConfig();
$this->_wpHelper = $helper;
parent::__construct($context, $data);
}
/**
* check if module enabled and ajax mode is enabled
*
* @return bool
*/
public function isLnEnabled() {
$is = false;
if($this->_wpHelper->isEnabled()) {
$is = ($this->_wpHelper->isAjaxEnabled()) ? true : false;
}
return $is;
}
}
+387
View File
@@ -0,0 +1,387 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block;
use Magento\Catalog\Model\Product\ProductList\Toolbar as ToolbarModel;
use Magento\Catalog\Helper\Product\ProductList;
/**
* Class Navigation
* @package WeltPixel\LayeredNavigation\Block
*/
class Navigation extends \Magento\LayeredNavigation\Block\Navigation
{
/**
* Catalog layer
*
* @var \Magento\Catalog\Model\Layer
*/
protected $_catalogLayer;
/**
* @var \Magento\Catalog\Model\Layer\FilterList
*/
protected $filterList;
/**
* @var \Magento\Catalog\Model\Layer\AvailabilityFlagInterface
*/
protected $visibilityFlag;
/**
* @var ProductList
*/
protected $_productListHelper;
/**
* Default Order field
*
* @var string
*/
protected $_orderField = null;
/**
* Default direction
*
* @var string
*/
protected $_direction = ProductList::DEFAULT_SORT_DIRECTION;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var \Magento\Framework\Registry
*/
protected $_registry;
/**
* @var \WeltPixel\LayeredNavigation\Model\AttributeOptions
*/
protected $_attributeOptions;
/**
* @var \Magento\Swatches\Helper\Data
*/
private $swatchHelper;
/**
* Navigation constructor.
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param \Magento\Catalog\Model\Layer\FilterList $filterList
* @param \Magento\Catalog\Model\Layer\AvailabilityFlagInterface $visibilityFlag
* @param ProductList $productListHelper
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
* @param \WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
* @param \Magento\Framework\Registry $registry
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
\Magento\Catalog\Model\Layer\FilterList $filterList,
\Magento\Catalog\Model\Layer\AvailabilityFlagInterface $visibilityFlag,
ProductList $productListHelper,
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions,
\Magento\Framework\Registry $registry,
\Magento\Swatches\Helper\Data $swatchHelper,
array $data = []
)
{
$this->_catalogLayer = $layerResolver->get();
$this->filterList = $filterList;
$this->visibilityFlag = $visibilityFlag;
$this->_productListHelper = $productListHelper;
$this->_wpHelper = $wpHelper;
$this->_attributeOptions = $attributeOptions;
$this->_registry = $registry;
$this->swatchHelper = $swatchHelper;
parent::__construct($context, $layerResolver, $filterList, $visibilityFlag, $data);
}
/**
* @return mixed
*/
public function isCategoryFilterVisible()
{
return $this->_wpHelper->showCategoriesBlock();
}
/**
* @return mixed
*/
public function isAjaxMode()
{
return $this->_wpHelper->isAjaxEnabled();
}
/**
* @return mixed
*/
public function isAjaxScrollToTop()
{
return $this->_wpHelper->isAjaxScrollToTopEnabled();
}
/**
* @return mixed
*/
public function isAutoClose()
{
return $this->_wpHelper->isAutoClose();
}
/**
* @return mixed
*/
public function noOfColumns() {
return $this->_wpHelper->getNoColumns();
}
/**
* @return mixed
*/
public function boxHeight() {
return $this->_wpHelper->getSlideDownHeight();
}
/**
* @return mixed
*/
public function filterColumnHeight() {
return $this->_wpHelper->getFilterColumnHeight();
}
/**
* check if current filter is a category filter
*
* @param $filter
* @return bool
*/
public function isCategoryFilter($filter)
{
return ($filter->getRequestVar() == $this->_wpHelper->getCategoryParamLabel()) ? true : false;
}
/**
* check if current filter is a rating filter
*
* @param $filter
* @return bool
*/
public function isRatingFilter($filter)
{
return ($filter->getRequestVar() == $this->_wpHelper->getRatingParamLabel()) ? true : false;
}
/**
* @return \Magento\Framework\Phrase|string
*/
public function getFilterButtonHtml()
{
return $this->_wpHelper->getFilterButtonStyle();
}
/**
* Return wp attribute options
*
* @param $attributeId
* @return mixed
*/
public function getWpAttributeOptions($attributeId)
{
return $this->_attributeOptions->getDisplayOptionsByAttribute($attributeId);
}
/**
* check if module enabled and ajax mode is enabled
*
* @return bool
*/
public function isLnEnabled() {
$is = false;
if($this->_wpHelper->isEnabled()) {
$is = ($this->_wpHelper->isAjaxEnabled()) ? true : false;
}
return $is;
}
/**
* set filter tab status
*
* @return string
*/
public function getActiveFilters() {
$stateFilters = $this->_catalogLayer->getState()->getFilters();
$stateFilterIds = [];
foreach ($stateFilters as $_filter) {
if (in_array($_filter->getFilter()->getRequestVar(), [$this->_wpHelper->getCategoryParamLabel(), $this->_wpHelper->getRatingParamLabel()])) {
continue;
}
$dataAttrId = $_filter->getFilter()->getAttributeModel()->getAttributeId();
$stateFilterIds[] = $dataAttrId;
}
$filters = $this->getFilters();
$activeFilters = [];
$ctr = 0;
$isSlideDownMode = ($this->_wpHelper->getSidebarStyle() == 2 ) ? true : false;
foreach($filters as $k => $filter) {
if($filter->getRequestVar() == $this->_wpHelper->getCategoryParamLabel() && !$isSlideDownMode) {
if(($filter->getItemsCount() > 0) && $this->_wpHelper->showCategoryFilterAs()) {
$activeFilters[] = $ctr; $ctr++;
}
continue;
} else {
if($filter->getItemsCount() > 0) {
if($isSlideDownMode) {
$activeFilters[] = $ctr;
$ctr++;
continue;
}
if($filter->getRequestVar() == $this->_wpHelper->getRatingParamLabel()) {
if($this->_wpHelper->getRatingFilterDisplay() == '1') $activeFilters[] = $ctr;
if($filter->getItemsCount()) $ctr++;
continue;
}
$attributeId = $filter->getAttributeModel()->getAttributeId();
$categoryVisibility = $this->getCategoryVisibility($attributeId);
if(!$categoryVisibility) {
continue;
}
if($attributeId) {
$wpOptions = $this->getWpAttributeOptions($attributeId);
if($wpOptions->getData()) {
if($wpOptions->getDisplayOption() == '1' || $wpOptions->getDisplayOption() == '2') {
$activeFilters[] = $ctr;
}
}
if ($this->swatchHelper->isSwatchAttribute($filter->getAttributeModel())) {
if($wpOptions->getDisplayOption() == '1') {
$activeFilters[] = $ctr;
}
}
if (in_array($attributeId, $stateFilterIds) && $wpOptions->getKeepOpenAfterFilter()) {
$activeFilters[] = $ctr;
}
}
$ctr++;
}
}
}
$activeFilters = array_unique($activeFilters);
$activeFiltersStr = implode(' ', $activeFilters);
return $activeFiltersStr;
}
/**
* Return current URL with rewrites and additional parameters
*
* @param array $params Query parameters
* @return string
*/
public function getPagerUrl($params = [])
{
$urlParams = [];
$urlParams['_current'] = true;
$urlParams['_escape'] = false;
$urlParams['_use_rewrite'] = true;
$urlParams['_query'] = $params;
return $this->getUrl('*/*/*', $urlParams);
}
/**
* Retrieve widget options in json format
*
* @param array $customOptions Optional parameter for passing custom selectors from template
* @return string
*/
public function getWidgetOptionsJson(array $customOptions = [])
{
$defaultMode = $this->_productListHelper->getDefaultViewMode($this->getModes());
$options = [
'mode' => ToolbarModel::MODE_PARAM_NAME,
'direction' => ToolbarModel::DIRECTION_PARAM_NAME,
'order' => ToolbarModel::ORDER_PARAM_NAME,
'limit' => ToolbarModel::LIMIT_PARAM_NAME,
'modeDefault' => $defaultMode,
'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION,
'orderDefault' => $this->getOrderField(),
'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode),
'url' => $this->getPagerUrl(),
];
$options = array_replace_recursive($options, $customOptions);
return json_encode(['productListToolbarForm' => $options]);
}
/**
* Get order field
*
* @return null|string
*/
protected function getOrderField()
{
if ($this->_orderField === null) {
$this->_orderField = $this->_productListHelper->getDefaultSortField();
}
return $this->_orderField;
}
/**
* @return bool
*/
public function getCategoryVisibility($attributeId = false)
{
if(!$attributeId) {
return true;
}
$visibility = true;
$category = $this->_registry->registry('current_category');
if ($attributeId > 0 && $category) {
$currentCatId = $category->getId();
$categoryVisibility = $this->getWpAttributeOptions($attributeId)->getCategoryVisibility();
$categoriesIds = $this->getWpAttributeOptions($attributeId)->getCategoryIds() ?? '';
$categoriesArr = explode(',', $categoriesIds);
if ($categoryVisibility == 1) {
if (in_array($currentCatId, $categoriesArr)) {
$visibility = true;
} else {
$visibility = false;
}
}
if ($categoryVisibility == 2) {
if (in_array($currentCatId, $categoriesArr)) {
$visibility = false;
} else {
$visibility = true;
}
}
}
return $visibility;
}
}
@@ -0,0 +1,370 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block\Navigation;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\View\Element\Template;
use Magento\Catalog\Model\Layer\Filter\FilterInterface;
/**
* Class FilterRenderer
* @package WeltPixel\LayeredNavigation\Block\Navigation
*/
class FilterRenderer extends \Magento\LayeredNavigation\Block\Navigation\FilterRenderer
{
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var \WeltPixel\LayeredNavigation\Model\AttributeOptions
*/
protected $_attributeOptions;
/**
* @var
*/
protected $_attributeId;
/**
* @var
*/
protected $_attributeOptionsObj;
/**
* @var int
*/
protected $maxPrice;
/**
* @var int
*/
protected $minPrice;
/**
* @var int
*/
protected $maxPriceX;
/**
* @var int
*/
protected $minPriceX;
/**
* @var \Magento\Framework\Registry
*/
protected $_registry;
/**
* @var \Magento\Framework\Pricing\PriceCurrencyInterface
*/
protected $_currency;
/**
* @var \Magento\Theme\Block\Html\Pager
*/
private $htmlPagerBlock;
/**
* @var ProductMetadataInterface
*/
protected $productMetadata;
/**
* FilterRenderer constructor.
* @param ProductMetadataInterface $productMetadata
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
* @param \WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $currency
* @param \Magento\Theme\Block\Html\Pager $htmlPagerBlock
* @param Template\Context $context
* @param array $data
*/
public function __construct(
ProductMetadataInterface $productMetadata,
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions,
\Magento\Framework\Registry $registry,
\Magento\Framework\Pricing\PriceCurrencyInterface $currency,
\Magento\Theme\Block\Html\Pager $htmlPagerBlock,
Template\Context $context,
array $data = []
)
{
$this->productMetadata = $productMetadata;
$this->_wpHelper = $wpHelper;
$this->_attributeOptions = $attributeOptions;
$this->_registry = $registry;
$this->_currency = $currency;
$this->htmlPagerBlock = $htmlPagerBlock;
parent::__construct($context, $data);
}
/**
* @param FilterInterface $filter
* @return string
*/
public function render(FilterInterface $filter)
{
$this->filter = $filter;
if ($this->_wpHelper->isEnabled()) {
if ($filter->getRequestVar() == 'price' && $this->_wpHelper->getPriceIsSliderMode()) {
$collection = $this->filter->getLayer()->getProductCollection();
$currentCatId = ($this->_registry->registry('current_category')) ? $this->_registry->registry('current_category')->getId() : "";
$basePriceData = $this->_registry->registry('price_filter');
if (is_array($basePriceData) && $currentCatId && array_key_exists($currentCatId, $basePriceData)) {
$this->minPriceX = $basePriceData[$currentCatId]['min'];
$this->maxPriceX = $basePriceData[$currentCatId]['max'];
} else {
$this->minPriceX = ($this->minPriceX == null) ? $collection->getMinPrice() : $this->minPriceX;
$this->maxPriceX = ($this->maxPriceX == null) ? $collection->getMaxPrice() : $this->maxPriceX;
}
$this->minPrice = ($this->minPrice == null) ? $collection->getMinPrice() : $this->minPrice;
$this->maxPrice = ($this->maxPrice == null) ? $collection->getMaxPrice() : $this->maxPrice;
$this->setTemplate('layer/slider.phtml');
} else {
$this->setTemplate('layer/filter.phtml');
}
}
$html = parent::render($filter);
return $html;
}
/**
* @return array
*/
public function getPriceConfigData()
{
$range = [
'minX' => floor($this->minPriceX),
'maxX' => ceil($this->maxPriceX),
'min' => floor($this->minPrice),
'max' => ceil($this->maxPrice),
'step' => 1,
'currency' => $this->_currency->getCurrencySymbol()
];
return $range;
}
/**
* @return bool
*/
public function priceIsInputType()
{
return $this->_wpHelper->canShowPriceInput();
}
/**
* @return string
*/
public function getSliderApplyUrl()
{
$params = [
'price' => $this->minPrice . '-' . $this->maxPrice,
$this->htmlPagerBlock->getPageVarName() => null
];
$urlParams = [];
$urlParams['_current'] = true;
$urlParams['_escape'] = false;
$urlParams['_use_rewrite'] = true;
$urlParams['_query'] = $params;
return $this->getUrl('*/*/*', $urlParams);
}
/**
* @return mixed
*/
public function getPriceStep()
{
$step = $this->_wpHelper->getPriceRangeStep();
return ($step > $this->maxPrice) ? $this->maxPrice : $step;
}
/**
* @param $filter
*/
public function setAttributeId($filter)
{
if ($filter->getRequestVar() == $this->_wpHelper->getCategoryParamLabel()) {
$this->_attributeId = $this->_wpHelper->getCategoryParamLabel();
} elseif ($filter->getRequestVar() == $this->_wpHelper->getRatingParamLabel()) {
$this->_attributeId = $this->_wpHelper->getRatingParamLabel();
} else {
$this->_attributeId = $filter->getAttributeModel()->getAttributeId();
}
}
/**
* Return wp attribute options
*
* @param $attributeId
* @return mixed
*/
public function getWpAttributeOptions()
{
$this->_attributeOptionsObj = ($this->_attributeId > 0) ? $this->_attributeOptions->getDisplayOptionsByAttribute($this->_attributeId) : '';
return $this->_attributeOptionsObj;
}
/**
* @return mixed
*/
public function getAttributeId()
{
return $this->_attributeId;
}
/**
* return the 'Visible Options' attribute configuration value
*
* @return mixed
*/
public function getVisibleItems()
{
if ($this->_attributeId > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getVisibleOptions();
} else {
return '';
}
}
return '';
}
/**
* return the 'Visible Options Step' attribute configuration value
*
* @return mixed
*/
public function getVisibleItemsStep()
{
if ($this->_attributeId > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getVisibleOptionsStep();
} else {
return '';
}
}
return '';
}
/**
* return the 'Show Qty' attribute configuration value
*
* @return mixed
*/
public function getShowQty()
{
if ($this->_attributeId == $this->_wpHelper->getRatingParamLabel()) {
return $this->_wpHelper->getRatingFilterCounter();
} elseif ($this->_attributeId == $this->_wpHelper->getCategoryParamLabel()) {
return '';
} else {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getShowQuantity();
}
return '';
}
}
/**
* return the 'Is Multiselect' attribute configuration value
*
* @return mixed
*/
public function getIsMultiSelect()
{
if ($this->_attributeId == $this->_wpHelper->getRatingParamLabel()) {
return $this->_wpHelper->isRatingFilterMultiselect();
} elseif ($this->_attributeId == $this->_wpHelper->getCategoryParamLabel()) {
return '';
} else {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getIsMultiselect();
}
return '';
}
}
/**
* return the 'Instant Search' attribute configuration value
*
* @return string
*/
public function canShowInstantSearch()
{
if ($this->_attributeId > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getInstantSearch();
}
return '';
}
return '';
}
/**
* return the 'Instant Search Mobile' attribute configuration value
*
* @return string
*/
public function canShowInstantSearchMobile()
{
if ($this->_attributeId > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getInstantSearchMobile();
}
return '';
}
return '';
}
/**
* @return string
*/
public function getCategoryParamLabel()
{
return $this->_wpHelper->getCategoryParamLabel();
}
/**
* @return string
*/
public function getRatingParamLabel()
{
return $this->_wpHelper->getRatingParamLabel();
}
/**
* @return string
*/
public function getSliderJsWidget()
{
$jsSliderWidget = 'jquery/ui-modules/widgets/slider';
$magentoVersion = $this->productMetadata->getVersion();
if (version_compare($magentoVersion, '2.4.4', '<')) {
$jsSliderWidget = 'jquery-ui-modules/slider';
}
return $jsSliderWidget;
}
}
@@ -0,0 +1,99 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block\Navigation;
/**
* Layered navigation state
*
* @api
* @since 100.0.2
*/
class State extends \Magento\LayeredNavigation\Block\Navigation\State
{
/**
* @var array
*/
protected $ratesStep = [
'0-20' => 1,
'21-40' => 2,
'41-60' => 3,
'61-80' => 4,
'81-100' => 5,
];
/**
* Catalog layer
*
* @var \Magento\Catalog\Model\Layer
*/
protected $_catalogLayer;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
array $data = []
) {
$this->_catalogLayer = $layerResolver->get();
$this->_wpHelper = $wpHelper;
parent::__construct($context,$layerResolver, $data);
if($this->_wpHelper->isEnabled()) {
$this->_template = 'WeltPixel_LayeredNavigation::layer/state.phtml';
}
}
/**
* @param $filter
* @return string
*/
public function getRateFilterLabel($filter) {
$selectedValue = $filter->getValue();
$countStars = 1;
if(is_array($selectedValue)) {
$val = $selectedValue[0].'-'.$selectedValue[1];
$countStars = $this->ratesStep[$val];
} else {
$valArr = explode('-', $selectedValue);
$val = $valArr[0].'-'.$valArr[1];
$countStars = $this->ratesStep[$val];
}
$label = '<div class="rating-summary" style="display: inline-block;margin-top: -5px;">
<div class="rating-result" title="up to '.$countStars*20 .'%"">
<span style="width:'.$countStars*20 .'%"></span>
</div>
</div>';
return $label;
}
/**
* @return string
*/
public function getCategoryParamLabel() {
return $this->_wpHelper->getCategoryParamLabel();
}
/**
* @return string
*/
public function getRatingParamLabel() {
return $this->_wpHelper->getRatingParamLabel();
}
}
@@ -0,0 +1,4 @@
Important notes:
- Extension files for Magento versions 2.4 or higher.
- Files NOT compatible with Magento version 2.0 - 2.3.x.
- Using different set of files for each Magento version for best performance.
+589
View File
@@ -0,0 +1,589 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Helper;
use Magento\Store\Model\ScopeInterface;
use \Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
/**
* Class Data
* @package WeltPixel\LayeredNavigation\Helper
*/
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
const SLIDE_IN_STYLE = 1;
const SLIDE_DOWN_STYLE = 2;
const FILTER_BUTTON_LABEL = 'Filter';
const PRICE_FILTER_SLIDER = 2;
const PRICE_FILTER_INPUT = 1;
const CATEGORY_PARAM_LABEL = 'cat';
const RATING_PARAM_LABEL = 'rat';
protected $_currentEngine = '';
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* @var int
*/
protected $_storeId;
/**
* @var Config
*/
private $pageConfig;
/**
* Data constructor.
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\View\Page\Config $pageConfig
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\View\Page\Config $pageConfig
)
{
$this->_storeManager = $storeManager;
$this->pageConfig = $pageConfig;
parent::__construct($context);
$this->_storeId = $this->getCurrentStoreId();
}
/**
* @return string
*/
public function getRatingParamLabel() {
return self::RATING_PARAM_LABEL;
}
/**
* @return string
*/
public function getCategoryParamLabel() {
return self::CATEGORY_PARAM_LABEL;
}
/**
* Return current store_id
*
* @return int
*/
public function getCurrentStoreId()
{
return $this->_storeManager->getStore()->getId();
}
/**
* @param int $storeId
* @return mixed
*/
public function isEnabled($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/general/enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function isAjaxEnabled($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/general/ajax', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function isAjaxScrollToTopEnabled($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/general/ajax_scroll_top', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function getSidebarStyle($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/sb_style', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function getNoColumns($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/slide_down_columns', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function getSlideDownHeight($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/slide_down_height', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function getFilterColumnHeight($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/filter_column_height', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function showCategoriesBlock($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/category_block', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function showCategoryFilterAs($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/show_category_filter_as', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function showCompareBlock($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/compare_block', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function showWishlistBlock($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/wishlist_block', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param int $storeId
* @return mixed
*/
public function showRecentlyOrderedBlock($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/recentlyordered_block', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function getFilterButton($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/filter_button', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function showInstantSearch($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/instant_search', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function showInstantSearchMobile($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/instant_search_mobile', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* Filter Button option
* 0-icon only
* 1-icon & label
* 2-label only
*
* @return \Magento\Framework\Phrase|string
*/
public function getFilterButtonStyle()
{
$slideDownModeAppend = ($this->getSidebarStyle() == self::SLIDE_DOWN_STYLE) ? "<span class='wp-slide-down-add'></span>" : '';
switch ($this->getFilterButton()) {
case 0:
$filterButtonHtml = "<b class='wp-slide-in'></b>" . $slideDownModeAppend;
break;
case 1:
$filterButtonHtml = "<b class='wp-slide-in'></b><b class='wp-filters-text'>" . /* @escapeNotVerified */ __(self::FILTER_BUTTON_LABEL) . "</b>" . $slideDownModeAppend;
break;
case 2:
$filterButtonHtml = __(self::FILTER_BUTTON_LABEL);
break;
default:
$filterButtonHtml = '';
}
return $filterButtonHtml;
}
/**
* @return bool
*/
public function getSlideMode() {
if($this->getSidebarStyle() == self::SLIDE_IN_STYLE) {
return 'slider-layer';
} else if($this->getSidebarStyle() == self::SLIDE_DOWN_STYLE) {
return 'slider-down-layer';
}
return false;
}
/**
* update class on body tag based on configuration settings
* the class is used for layered navigation view mode setting
*/
public function updateSliderBodyClass() {
if($this->getSlideMode()) {
$this->pageConfig->addBodyClass($this->getSlideMode());
} else {
$this->pageConfig->addBodyClass('default-layer');
}
}
/**
* Check the engine provider is 'elasticsearch'
* @deprecated
*
* @return bool
*/
public function isElasticSearchEngine() {
if(!$this->_currentEngine) {
$this->_currentEngine = $this->scopeConfig->getValue(EngineInterface::CONFIG_ENGINE_PATH, ScopeInterface::SCOPE_STORE);
}
if($this->_currentEngine == 'elasticsearch' || $this->_currentEngine == 'elasticsearch5' || $this->_currentEngine == 'elasticsearch6'
|| $this->_currentEngine == 'elasticsearch7' || $this->_currentEngine == 'elasticsearch8') {
return true;
}
return false;
}
/**
* Check the engine provider is 'elasticsearch' or 'opensearch'
*
* @return bool
*/
public function isElasticOrOpenSearchEngine() {
if(!$this->_currentEngine) {
$this->_currentEngine = $this->scopeConfig->getValue(EngineInterface::CONFIG_ENGINE_PATH, ScopeInterface::SCOPE_STORE);
}
if($this->_currentEngine == 'elasticsearch' || $this->_currentEngine == 'elasticsearch5' || $this->_currentEngine == 'elasticsearch6'
|| $this->_currentEngine == 'elasticsearch7' || $this->_currentEngine == 'opensearch') {
return true;
}
return false;
}
/**
* @return mixed
*/
public function getPriceRangeStep() {
return $this->scopeConfig->getValue('catalog/layered_navigation/price_range_step', ScopeInterface::SCOPE_STORE);
}
/**
* @param null $storeId
* @return mixed
*/
public function getPriceFilterStyle($storeId = null) {
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/price_filter', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @return bool
*/
public function getPriceIsSliderMode() {
$sliderMode = false;
if($this->getPriceFilterStyle() == self::PRICE_FILTER_SLIDER) {
$sliderMode = true;
}
return $sliderMode;
}
/**
* @param null $storeId
* @return mixed
*/
public function getPriceFilterInput($storeId = null) {
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/price_filter_input', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @return bool
*/
public function canShowPriceInput() {
$isInput = false;
$isInputSet = ($this->getPriceFilterInput() == self::PRICE_FILTER_INPUT) ? true : false;
if($this->getPriceIsSliderMode() && $isInputSet) {
$isInput = true;
}
return $isInput;
}
/**
* @param null $storeId
* @return mixed
*/
public function isRatingFilterEnabled($storeId = null) {
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @return bool|mixed
*/
public function getRatingFilterName($storeId = null) {
$name = false;
if($this->isRatingFilterEnabled() && $this->isEnabled()) {
$name = $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter_name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
return $name;
}
/**
* @param null $storeId
* @return mixed
*/
public function getRatingFilterPosition($storeId = null) {
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter_position', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function isRatingFilterMultiselect($storeId = null) {
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter_multiselect', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function getRatingFilterDisplay($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter_display', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function getRatingFilterCounter($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/rating_filter_counter', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return mixed
*/
public function isAutoClose($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/auto_close_sidebar', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return bool
*/
public function isShowHideDesktopFilterEnabled($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/allow_layered_show_hide', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getShowHideDesktopFilterState($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/layered_show_hide_state', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalSidebarDesignVersion($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_sb_design_version', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalSidebarFilterPosition($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_sb_design_v2_filter_position', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function isHorizontalSidebarStickyEnabled($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_sb_sticky_enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getSelectedFiltersOptions($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/sb_selected_filters_options', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return boolean
*/
public function displayMultiselectAttributeSelectedOptions($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/display_multiselect_selected_options', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return int
*/
public function getMobileThreshold($storeId = null)
{
$mobileThreshold = (int) $this->scopeConfig->getValue(
'weltpixel_frontend_options/breakpoints/screen__m',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
return ($mobileThreshold) ? $mobileThreshold : 768;
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalV3FiltersButtonColor($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_filters_button_color', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalV3FiltersTextColor($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_filters_text_color', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalV3FiltersButtonHoverColor($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_filters_button_hover_color', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalV3FiltersTextHoverColor($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_filters_text_hover_color', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalFiltersBorder($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_border', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalFiltersBorderRadius($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_border_radius', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalFiltersBorderColor($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_v3_border_color', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param null $storeId
* @return string
*/
public function getHorizontalBoxShadow($storeId = null)
{
return $this->scopeConfig->getValue('weltpixel_layerednavigation/sidebar/horizontal_box_shadow', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2025 WeltPixel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,50 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model;
class AttributeOptions extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\DataObject\IdentityInterface
{
const CACHE_TAG = 'weltpixel_ln_attribute_options';
const DISPLAY_OPTION_DEF_VAL = 0;
const DISPLAY_OPTION_OPEN_VAL = 1;
const VISIBLE_OPTIONS_DEF_VAL = 99;
const VISIBLE_OPTIONS_STEP_DEF_VAL = 99;
/**
* @var string
*/
protected $_cacheTag = 'weltpixel_ln_attribute_options';
/**
* @var string
*/
protected $_eventPrefix = 'weltpixel_ln_attribute_options';
protected function _construct()
{
$this->_init('WeltPixel\LayeredNavigation\Model\ResourceModel\AttributeOptions');
}
/**
* @return array|string[]
*/
public function getIdentities()
{
return [self::CACHE_TAG . '_' . $this->getId()];
}
/**
* @param $attributeId
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getDisplayOptionsByAttribute($attributeId) {
$this->_getResource()->loadDisplayOptionsByAttribute($this, $attributeId);
return $this;
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class CategoryShowAs
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class CategoryShowAs implements ArrayInterface
{
/**
* @var array
*/
protected $_showAs = array(
0 => 'Closed',
1 => 'Fully Opened'
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_showAs as $id => $showAs) :
$options[] = array(
'value' => $id,
'label' => $showAs
);
endforeach;
return $options;
}
}
@@ -0,0 +1,42 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class FilterButton
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class FilterButton implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
0 => 'Icon Only',
1 => 'Icon + Label',
2 => 'Label Only',
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
@@ -0,0 +1,42 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class FilterDisplay
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class FilterDisplay implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
0 => 'Close',
1 => 'Open',
2 => 'Expand',
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class FilterShowHideState
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class FilterShowHideState implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = [
'open' => 'Open',
'closed' => 'Closed',
];
/**
* @return array
*/
public function toOptionArray()
{
$options = [];
foreach ($this->_styles as $id => $style) :
$options[] = [
'value' => $id,
'label' => $style
];
endforeach;
return $options;
}
}
@@ -0,0 +1,73 @@
<?php
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
class HorizontalSidebarDesignVersion implements SourceInterface, OptionSourceInterface
{
/**
* block type
*/
const VERSION_1 = 'v1';
const VERSION_2 = 'v2';
const VERSION_3 = 'v3';
/**
* Prepare display options.
*
* @return array
*/
public function getAvailableModes()
{
return [
self::VERSION_1 => __('Version 1'),
self::VERSION_2 => __('Version 2'),
self::VERSION_3 => __('Version 3'),
];
}
/**
* Retrieve All options
*
* @return array
*/
public function getAllOptions()
{
$result = [];
foreach ($this->getAvailableModes() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
/**
* Retrieve Option value text
*
* @param string $value
* @return mixed
*/
public function getOptionText($value)
{
$options = $this->getAvailableModes();
return isset($options[$value]) ? $options[$value] : null;
}
/**
* Return array of options as value-label pairs
*
* @return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...)
*/
public function toOptionArray()
{
return $this->getAllOptions();
}
}
@@ -0,0 +1,71 @@
<?php
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
class HorizontalSidebarFilterPosition implements SourceInterface, OptionSourceInterface
{
/**
* block type
*/
const LEFT = 'left';
const CENTER = 'center';
/**
* Prepare display options.
*
* @return array
*/
public function getAvailableModes()
{
return [
self::LEFT => __('Left'),
self::CENTER => __('Center')
];
}
/**
* Retrieve All options
*
* @return array
*/
public function getAllOptions()
{
$result = [];
foreach ($this->getAvailableModes() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
/**
* Retrieve Option value text
*
* @param string $value
* @return mixed
*/
public function getOptionText($value)
{
$options = $this->getAvailableModes();
return isset($options[$value]) ? $options[$value] : null;
}
/**
* Return array of options as value-label pairs
*
* @return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...)
*/
public function toOptionArray()
{
return $this->getAllOptions();
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class PriceFilter
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class PriceFilter implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
'1' => 'Default',
'2' => 'Slider'
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class RatingFilterDisplay
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class RatingFilterDisplay implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
0 => 'Close',
1 => 'Open'
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
@@ -0,0 +1,43 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class SidebarStyle
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class SidebarStyle implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
'0' => 'Default',
'1' => 'Slide In',
'2' => 'Slide Down',
'3' => 'Horizontal View'
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
@@ -0,0 +1,120 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
use \Magento\Store\Model\StoreManagerInterface;
use \Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
/**
* Class SlideDownFilterColumns
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class SlideDownFilterColumns implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
'99%' => '1 column',
'48.5%' => '2 columns',
'31.9%' => '3 columns',
'23.4%' => '4 columns',
'18.4%' => '5 columns',
'15.2%' => '6 columns',
);
/**
* @var array
*/
protected $_pearl_styles = array(
'99%' => '1 column',
'49%' => '2 columns',
'32.33%' => '3 columns',
'24%' => '4 columns',
'19%' => '5 columns',
'16.33%' => '6 columns',
);
/**
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;
/** @var ThemeProviderInterface */
protected $themeProvider;
public function __construct(
StoreManagerInterface $storeManager,
ScopeConfigInterface $scopeConfig,
ThemeProviderInterface $themeProvider
)
{
$this->storeManager = $storeManager;
$this->scopeConfig = $scopeConfig;
$this->themeProvider = $themeProvider;
}
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
if($this->_isPearlTheamActive()) {
foreach ($this->_pearl_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
} else {
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
}
return $options;
}
/**
* @return bool
* @throws \Exception
*/
protected function _isPearlTheamActive()
{
try {
$store = $this->storeManager->getStore();
$themeId = $this->scopeConfig->getValue(
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store->getId()
);
$theme = $this->themeProvider->getThemeById($themeId);
$themePath = $theme->getThemePath();
if (strpos($themePath, 'Pearl') !== false) {
return true;
}
return false;
} catch (\Exception $ex) {
throw new \Exception('Store with id or code ' . $store->getId() . ' not found.');
}
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* Class SortBy
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class SortBy implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
'position' => 'Position',
'name' => 'Name'
);
/**
* @return array
*/
public function toOptionArray()
{
$options = array();
foreach ($this->_styles as $id => $style) :
$options[] = array(
'value' => $id,
'label' => $style
);
endforeach;
return $options;
}
}
+152
View File
@@ -0,0 +1,152 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Layer;
use Magento\Framework\App\RequestInterface;
use WeltPixel\LayeredNavigation\Model\AttributeOptions;
/**
* Class Filter
* @package WeltPixel\LayeredNavigation\Model\Layer
*/
class Filter
{
/** @var \Magento\Framework\App\RequestInterface */
protected $request;
/**
* @var AttributeOptions
*/
protected $_wpAttributeOptions;
/**
* @var array
*/
protected $_ids = [];
/**
* Filter constructor.
* @param RequestInterface $request
* @param AttributeOptions $attributeOptions
*/
public function __construct(
RequestInterface $request,
AttributeOptions $attributeOptions
)
{
$this->request = $request;
$this->_wpAttributeOptions = $attributeOptions;
}
/**
* Get option url. If it has been filtered, return removed url. Else return filter url
*
* @param \Magento\Catalog\Model\Layer\Filter\Item $item
* @return mixed
*/
public function getItemUrl($item)
{
if ($this->isSelected($item)) {
return $item->getRemoveUrl();
}
return $item->getUrl();
}
/**
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
* @param bool|true $explode
* @return array|mixed
*/
public function getFilterValue($filter, $explode = true)
{
$filterValue = $this->request->getParam($filter->getRequestVar());
if (empty($filterValue)) {
return [];
}
return $explode ? explode(',', $filterValue) : $filterValue;
}
/**
* Checks whether the option reduces the number of results
*
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
* @param int $optionCount Count of search results with this option
* @param int $totalSize Current search results count
* @return bool
*/
public function isOptionReducesResults($filter, $optionCount, $totalSize)
{
$result = $optionCount <= $totalSize;
if ($this->isShowZero($filter)) {
return $result;
}
return $optionCount && $result;
}
/**
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
* @return bool
*/
public function isShowZero($filter)
{
return false;
}
/**
* @param $filter
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function isMainFilter($filter) {
if(empty($this->_ids)){
$this->_ids = $this->getStateAttributesIds($filter);
}
$isMulti = false;
if(count($this->_ids) <= 1) {
$isMulti = true;
if(!empty($this->_ids)) {
$isMulti = $this->isMultiselect($this->_ids[0]);
}
}
return $isMulti;
}
/**
* @param $attrId
*/
public function isMultiselect($attrId) {
$wpLnAttributeOptions = ($attrId) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attrId) : false;
$isMultiselect = ($wpLnAttributeOptions) ? $wpLnAttributeOptions->getIsMultiselect() : false;
return $isMultiselect;
}
/**
* @param Layer $layer
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function getStateAttributesIds($filter)
{
$layer = $filter->getLayer();
foreach ($layer->getState()->getFilters() as $filter) {
if ($model = $filter->getFilter()->getData('attribute_model')) {
$this->_ids[] = $model->getId();
}
}
return array_unique($this->_ids);
}
}
@@ -0,0 +1,361 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Layer\Filter;
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
use WeltPixel\LayeredNavigation\Model\Layer\Filter as LayerFilter;
use WeltPixel\LayeredNavigation\Model\AttributeOptions;
/**
* Class Attribute
* @package WeltPixel\LayeredNavigation\Model\Layer\Filter
*/
class Attribute extends AbstractFilter
{
/**
* @var LayerHelper
*/
protected $_moduleHelper;
/**
* @var bool
*/
protected $_isFilter = true;
/**
* @var \Magento\Framework\Filter\StripTags
*/
protected $tagFilter;
/**
* @var LayerFilter
*/
protected $_layerFilter;
/**
* @var AttributeOptions
*/
protected $_wpAttributeOptions;
/**
* @var
*/
protected $_requestParamVal;
/**
* Resource instance
*
* @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute
*/
protected $_resource;
/**
* @var
*/
protected $_originalCollection;
/**
* @var \Magento\Framework\Stdlib\StringUtils
*/
protected $string;
/**
* @var int
*/
protected $selectedOptionsCounter = 0;
/**
* Attribute constructor.
* @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Layer $layer
* @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder
* @param \Magento\Framework\Filter\StripTags $tagFilter
* @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory $filterAttributeFactory
* @param LayerHelper $moduleHelper
* @param LayerFilter $layerFilter
* @param AttributeOptions $attributeOptions
* @param \Magento\Framework\Stdlib\StringUtils $string
* @param array $data
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function __construct(
\Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer $layer,
\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
\Magento\Framework\Filter\StripTags $tagFilter,
\Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory $filterAttributeFactory,
LayerHelper $moduleHelper,
LayerFilter $layerFilter,
AttributeOptions $attributeOptions,
\Magento\Framework\Stdlib\StringUtils $string,
array $data = []
)
{
parent::__construct(
$filterItemFactory,
$storeManager,
$layer,
$itemDataBuilder,
$data
);
$this->_resource = $filterAttributeFactory->create();
$this->tagFilter = $tagFilter;
$this->_moduleHelper = $moduleHelper;
$this->_layerFilter = $layerFilter;
$this->_wpAttributeOptions = $attributeOptions;
$this->string = $string;
}
/**
* @inheritdoc
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_moduleHelper->isEnabled()) {
return $this->_getBaseApply($request);
}
$attributeValue = $request->getParam($this->_requestVar);
if (empty($attributeValue)) {
$this->_isFilter = false;
return $this;
}
$this->_requestParamVal = $this->_requestVar;
$attributeValue = explode(',', $attributeValue);
$this->selectedOptionsCounter = count($attributeValue);
$state = $this->getLayer()->getState();
foreach ($attributeValue as $value) {
$label = $this->getOptionText($value);
$state->addFilter($this->_createItem($label, $value));
}
$attribute = $this->getAttributeModel();
if (!$this->isMultiselect($attribute->getId()) && count($attributeValue) > 1) {
$attributeValue = array_slice($attributeValue, 0, 1);
}
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
if(!$this->_originalCollection) {
$this->_originalCollection = $productCollection->getCollectionClone();
}
if (count($attributeValue) > 1) {
if($this->_moduleHelper->isElasticOrOpenSearchEngine()) {
$productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue);
}
else {
$productCollection->addFieldToFilter($attribute->getAttributeCode(), ['in' => $attributeValue]);
}
} else {
$productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue[0]);
}
return $this;
}
/**
* Retrieve resource instance
*
* @return \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute
*/
protected function _getResource()
{
return $this->_resource;
}
/**
* @inheritdoc
*/
protected function _getItemsData()
{
if (!$this->_moduleHelper->isEnabled()) {
return $this->_getBaseItemsData();
}
$attribute = $this->getAttributeModel();
$wpLnAttributeOptions = ($attribute->getId()) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attribute->getId()) : false;
if(!$wpLnAttributeOptions->getIsMultiselect() && $this->_isFilter) {
return [];
}
/** @var \WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
if ($this->_isFilter && ( $this->_layerFilter->isMainFilter($this) || $wpLnAttributeOptions->getIsMultiselect())) {
$productCollection = $productCollection->getCollectionClone()
->removeAttributeSearch($attribute->getAttributeCode());
}
$optionsFacetedData = $productCollection->getFacetedData($attribute->getAttributeCode());
if (count($optionsFacetedData) === 0
&& $this->getAttributeIsFilterable($attribute) !== static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
) {
return $this->itemDataBuilder->build();
}
$productSize = $productCollection->getSize();
$itemData = [];
$checkCount = false;
$options = $attribute->getFrontend()->getSelectOptions();
$counter = false;
foreach ($options as $option) {
$sorted = false;
if (empty($option['value'])) {
continue;
}
$value = $option['value'];
if($counter) {
$count = isset($counter[$value]) ? (int)$counter[$value] : 0;
} else {
$count = isset($optionsFacetedData[$value]['count']) ? (int)$optionsFacetedData[$value]['count'] : 0;
}
// Check filter type
if ($this->getAttributeIsFilterable($attribute) == static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS && (!$this->_layerFilter->isOptionReducesResults($this, $count, $productSize)) && $count == 0) {
continue;
}
if ($count > 0) {
$checkCount = true;
}
$itemData[] = [
'label' => $this->tagFilter->filter($option['label']),
'value' => $value,
'count' => $count
];
}
if ($checkCount) {
if ($wpLnAttributeOptions->getSortBy() == 2) {
usort($itemData, [$this, '_compareAz']);
$sorted = true;
}
foreach ($itemData as $item) {
$this->itemDataBuilder->addItemData($item['label'], $item['value'], $item['count']);
}
}
if ($wpLnAttributeOptions->getSortBy() == 2 && !$sorted) {
usort($options, [$this, '_compareAz']);
}
return $this->itemDataBuilder->build();
}
/**
* return attribute custom 'is_multiselect' option
*
* @param $attrId
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function isMultiselect($attrId)
{
$wpLnAttributeOptions = ($attrId) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attrId) : false;
$isMultiselect = ($wpLnAttributeOptions) ? $wpLnAttributeOptions->getIsMultiselect() : false;
return $isMultiselect;
}
/**
* @param $a
* @param $b
* @return int
*/
protected function _compareAz($a, $b)
{
return strcmp($a["label"], $b["label"]);
}
/**
* @param $request
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _getBaseApply($request){
$attributeValue = $request->getParam($this->_requestVar);
if (empty($attributeValue) && !is_numeric($attributeValue)) {
return $this;
}
$attribute = $this->getAttributeModel();
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()
->getProductCollection();
$productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue);
$label = $this->getOptionText($attributeValue);
$this->getLayer()
->getState()
->addFilter($this->_createItem($label, $attributeValue));
$this->setItems([]); // set items to disable show filtering
return $this;
}
/**
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _getBaseItemsData(){
$attribute = $this->getAttributeModel();
$this->_requestVar = $attribute->getAttributeCode();
$options = $attribute->getFrontend()->getSelectOptions();
$optionsCount = $this->_getResource()->getCount($this);
foreach ($options as $option) {
if (is_array($option['value'])) {
continue;
}
if ($this->string->strlen($option['value'])) {
// Check filter type
if ($this->getAttributeIsFilterable($attribute) == self::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS) {
if (!empty($optionsCount[$option['value']])) {
$this->itemDataBuilder->addItemData(
$this->tagFilter->filter($option['label']),
$option['value'],
$optionsCount[$option['value']]
);
}
} else {
$this->itemDataBuilder->addItemData(
$this->tagFilter->filter($option['label']),
$option['value'],
isset($optionsCount[$option['value']]) ? $optionsCount[$option['value']] : 0
);
}
}
}
return $this->itemDataBuilder->build();
}
/**
* @return int
*/
public function getSelectedOptionsCounter()
{
return $this->selectedOptionsCounter;
}
}
@@ -0,0 +1,148 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Layer\Filter;
use Magento\CatalogSearch\Model\Layer\Filter\Category as AbstractFilter;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
use WeltPixel\LayeredNavigation\Model\Layer\Filter as LayerFilter;
/**
* Class Category
* @package WeltPixel\LayeredNavigation\Model\Layer\Filter
*/
class Category extends AbstractFilter
{
/** @var \WeltPixel\LayeredNavigation\Helper\Data */
protected $_moduleHelper;
/** @var bool Is Filterable Flag */
protected $_isFilter = false;
/** @var \Magento\Framework\Escaper */
private $escaper;
/** @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Category */
private $dataProvider;
/**
* Category constructor.
* @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Layer $layer
* @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory $categoryDataProviderFactory
* @param LayerHelper $moduleHelper
* @param LayerFilter $layerFilter
* @param array $data
*/
public function __construct(
\Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer $layer,
\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
\Magento\Framework\Escaper $escaper,
\Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory $categoryDataProviderFactory,
LayerHelper $moduleHelper,
LayerFilter $layerFilter,
array $data = []
)
{
parent::__construct(
$filterItemFactory,
$storeManager,
$layer,
$itemDataBuilder,
$escaper,
$categoryDataProviderFactory,
$data
);
$this->escaper = $escaper;
$this->_moduleHelper = $moduleHelper;
$this->_layerFilter = $layerFilter;
$this->dataProvider = $categoryDataProviderFactory->create(['layer' => $this->getLayer()]);
}
/**
* @inheritdoc
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_moduleHelper->isEnabled()) {
return parent::apply($request);
}
$categoryId = $request->getParam($this->_requestVar);
if (empty($categoryId)) {
return $this;
}
$categoryIds = [];
foreach (explode(',', $categoryId) as $key => $id) {
$this->dataProvider->setCategoryId($id);
$categoryIds[] = $id;
if ($this->dataProvider->isValid()) {
$category = $this->dataProvider->getCategory();
if ($request->getParam('id') != $id) {
$this->getLayer()->getState()->addFilter($this->_createItem($category->getName(), $id));
}
}
}
if (sizeof($categoryIds)) {
$this->_isFilter = true;
$this->getLayer()->getProductCollection()->addLayerCategoryFilter($categoryIds);
}
return $this;
}
/**
* @return array
* @throws \Magento\Framework\Exception\StateException
*/
protected function _getItemsData()
{
if (!$this->_moduleHelper->isEnabled()) {
return parent::_getItemsData();
}
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
if ($this->_isFilter) {
$productCollection = $productCollection->getCollectionClone()
->removeAttributeSearch('category_ids');
}
$optionsFacetedData = $productCollection->getFacetedData('category');
$category = $this->dataProvider->getCategory();
$categories = $category->getChildrenCategories();
$collectionSize = $productCollection->getSize();
if ($category->getIsActive()) {
foreach ($categories as $category) {
$count = isset($optionsFacetedData[$category->getId()]) ? $optionsFacetedData[$category->getId()]['count'] : 0;
if ($category->getIsActive()
&& $this->_layerFilter->isOptionReducesResults($this, $count, $collectionSize)
) {
$this->itemDataBuilder->addItemData(
$this->escaper->escapeHtml($category->getName()),
$category->getId(),
$count
);
}
}
}
return $this->itemDataBuilder->build();
}
}
@@ -0,0 +1,341 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Layer\Filter;
use Magento\CatalogSearch\Model\Layer\Filter\Price as AbstractFilter;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
use WeltPixel\LayeredNavigation\Model\AttributeOptions;
/**
* Class Price
* @package WeltPixel\LayeredNavigation\Model\Layer\Filter
*/
class Price extends AbstractFilter
{
/** @var \WeltPixel\LayeredNavigation\Helper\Data */
protected $_moduleHelper;
/** @var array|null Filter value */
protected $_filterVal = null;
/** @var \Magento\Tax\Helper\Data */
protected $_taxHelper;
/** @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Price */
private $dataProvider;
/** @var \Magento\Framework\Pricing\PriceCurrencyInterface */
private $priceCurrency;
/** @var \Magento\Framework\Registry */
protected $_registry;
protected $_scopeConfig;
/**
* @var AttributeOptions
*/
protected $_wpAttributeOptions;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var int
*/
protected $selectedOptionsCounter = 0;
/**
* Price constructor.
* @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Layer $layer
* @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder
* @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Framework\Search\Dynamic\Algorithm $priceAlgorithm
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory $algorithmFactory
* @param \Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory $dataProviderFactory
* @param \Magento\Tax\Helper\Data $taxHelper
* @param LayerHelper $moduleHelper
* @param AttributeOptions $attributeOptions
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
* @param \Magento\Framework\Registry $registry
* @param array $data
*/
public function __construct(
\Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer $layer,
\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource,
\Magento\Customer\Model\Session $customerSession,
\Magento\Framework\Search\Dynamic\Algorithm $priceAlgorithm,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory $algorithmFactory,
\Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory $dataProviderFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Tax\Helper\Data $taxHelper,
LayerHelper $moduleHelper,
AttributeOptions $attributeOptions,
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
\Magento\Framework\Registry $registry,
array $data = []
)
{
parent::__construct(
$filterItemFactory,
$storeManager,
$layer,
$itemDataBuilder,
$resource,
$customerSession,
$priceAlgorithm,
$priceCurrency,
$algorithmFactory,
$dataProviderFactory,
$data
);
$this->priceCurrency = $priceCurrency;
$this->dataProvider = $dataProviderFactory->create(['layer' => $this->getLayer()]);
$this->_moduleHelper = $moduleHelper;
$this->_taxHelper = $taxHelper;
$this->_registry = $registry;
$this->_scopeConfig = $scopeConfig;
$this->_wpAttributeOptions = $attributeOptions;
$this->_wpHelper = $wpHelper;
}
/**
* @inheritdoc
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
$priceRangeCalculation = $this->_scopeConfig->getValue(
\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
if($priceRangeCalculation != 'auto') {
return parent::apply($request);
}
$filterEntry = [];
if (!$this->_moduleHelper->isEnabled()) {
return parent::apply($request);
}
/**
* Filter must be string: $fromPrice-$toPrice
*/
$filter = $strFilter = $request->getParam($this->getRequestVar());
if (!$filter || is_array($filter)) {
return $this;
}
$collection = $this->getLayer()->getProductCollection();
$baseCollection = clone $collection;
$currentCatId = $this->_registry->registry('current_category') ? $this->_registry->registry('current_category')->getId() : false;
$priceFilter = $this->_registry->registry('price_filter') ?: [];
if ($currentCatId) {
if (!array_key_exists($currentCatId, $priceFilter)) {
$basePriceData = [
'min' => $baseCollection->getMinPrice(),
'max' => $baseCollection->getMaxPrice()
];
$filterEntry = [
$currentCatId => $basePriceData
];
$this->_registry->register('price_filter', $filterEntry);
}
}
$filterParams = explode(',', $filter);
$this->selectedOptionsCounter = count($filterParams);
$attribute = $this->getAttributeModel();
$wpLnAttributeOptions = ($attribute->getId()) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attribute->getId()) : false;
if (!$this->_wpHelper->getPriceIsSliderMode() && $wpLnAttributeOptions->getIsMultiselect()) {
$filterConditions = [];
foreach ($filterParams as $filterParam) {
$filter = $this->dataProvider->validateFilter($filterParam);
if (!$filter) {
continue;
}
$this->dataProvider->setInterval($filter);
$priorFilters = $this->dataProvider->getPriorFilters($filterParams);
if ($priorFilters) {
$this->dataProvider->setPriorIntervals($filterParams);
}
list($from, $to) = $this->_filterVal = $filter;
$filterConditions[] = [
'attribute' => 'price',
['from' => $from, 'to' => $to]
];
$this->getLayer()->getState()->addFilter(
$this->_createItem($this->_renderRangeLabel(empty($from) ? 0 : $from, $to), $filter)
);
}
$this->getLayer()->getProductCollection()->addAttributeToFilter(
$filterConditions
);
} else {
$filter = $this->dataProvider->validateFilter($filterParams[0]);
if (!$filter) {
return $this;
}
$this->dataProvider->setInterval($filter);
$priorFilters = $this->dataProvider->getPriorFilters($filterParams);
if ($priorFilters) {
$this->dataProvider->setPriorIntervals($priorFilters);
}
list($from, $to) = $this->_filterVal = $filter;
$this->getLayer()->getProductCollection()->addFieldToFilter(
'price',
['from' => $from, 'to' => $to]
);
$this->getLayer()->getState()->addFilter(
$this->_createItem($this->_renderRangeLabel(empty($from) ? 0 : $from, $to), $filter)
);
}
return $this;
}
/**
* @inheritdoc
*/
protected function _renderRangeLabel($fromPrice, $toPrice, $isLast = false)
{
if (!$this->_moduleHelper->isEnabled()) {
return parent::_renderRangeLabel($fromPrice, $toPrice, $isLast);
}
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
if ($toPrice === '' || $isLast) {
return __('%1 and above', $formattedFromPrice);
} elseif ($fromPrice == $toPrice && $this->dataProvider->getOnePriceIntervalValue()) {
return $formattedFromPrice;
} else {
return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
}
}
/**
* Get data array for building attribute filter items
*
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getItemsData()
{
/*
if (!$this->_moduleHelper->isEnabled()) {
return parent::_getItemsData();
}
*/
$attribute = $this->getAttributeModel();
$this->_requestVar = $attribute->getAttributeCode();
$wpLnAttributeOptions = ($attribute->getId()) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attribute->getId()) : false;
if (!$this->_wpHelper->getPriceIsSliderMode() && !$wpLnAttributeOptions->getIsMultiselect() && $this->_filterVal) {
return [];
}
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
if ($this->_filterVal) {
/** @type \WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection $productCollectionClone */
$productCollection = $productCollection->getCollectionClone()
->removeAttributeSearch(['price.from', 'price.to']);
}
$facets = $productCollection->getFacetedData($attribute->getAttributeCode());
$data = [];
if (count($facets) > 1) {
$lastFacet = array_key_last($facets);
foreach ($facets as $key => $aggregation) {
$count = $aggregation['count'];
if (strpos($key, '_') === false) {
continue;
}
$isLast = $lastFacet === $key;
$data[] = $this->prepareData($key, $count, $wpLnAttributeOptions->getIsMultiselect(), $isLast);
}
}
return $data;
}
/**
* @param string $key
* @param int $count
* @param bool $isMultiSelect
* @param boolean $isLast
* @return array
*/
private function prepareData($key, $count, $isMultiSelect, $isLast = false)
{
list($from, $to) = explode('_', $key);
if ($from == '*') {
$from = $this->getFrom($to);
}
if ($to == '*') {
$to = $this->getTo($to);
}
$label = $this->_renderRangeLabel(
empty($from) ? 0 : $from * $this->getCurrencyRate(),
empty($to) ? $to : $to * $this->getCurrencyRate(),
$isLast
);
$value = $from . '-' . $to;
if (!$isMultiSelect) {
$value .= $this->dataProvider->getAdditionalRequestData();
}
$data = [
'label' => $label,
'value' => $value,
'count' => $count,
'from' => $from,
'to' => $to,
];
return $data;
}
/**
* @return int
*/
public function getSelectedOptionsCounter()
{
return $this->selectedOptionsCounter;
}
}
@@ -0,0 +1,236 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Nagy Attila @ Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\Layer\Filter;
use Magento\Catalog\Model\Layer;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
/**
* Layer category filter
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Rating extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
{
/**
* Active Category Id
*
* @var int
*/
protected $_categoryId;
/**
* Applied Category
*
* @var \Magento\Catalog\Model\Category
*/
protected $_appliedCategory;
/**
* Core data
*
* @var \Magento\Framework\Escaper
*/
protected $_escaper;
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry;
/**
* @var CategoryDataProvider
*/
private $dataProvider;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var int
*/
protected $selectedOptionsCounter = 0;
/**
* Rating constructor.
* @param \Magento\Framework\Registry $coreRegistry
* @param Layer\Filter\ItemFactory $filterItemFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param Layer $layer
* @param Layer\Filter\Item\DataBuilder $itemDataBuilder
* @param \Magento\Framework\Escaper $escaper
* @param LayerHelper $moduleHelper
* @param array $data
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function __construct(
\Magento\Framework\Registry $coreRegistry,
\Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer $layer,
\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
\Magento\Framework\Escaper $escaper,
LayerHelper $moduleHelper,
array $data = []
) {
parent::__construct($filterItemFactory, $storeManager, $layer, $itemDataBuilder, $data);
$this->_escaper = $escaper;
$this->_wpHelper = $moduleHelper;
$this->_requestVar = $this->_wpHelper->getRatingParamLabel();
$this->_coreRegistry = $coreRegistry;
}
/**
* Apply category filter to layer
*
* @param \Magento\Framework\App\RequestInterface $request
* @return $this
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
/**
* Filter must be string: $fromPrice-$toPrice
*/
$filter = $request->getParam($this->getRequestVar());
if (!$filter) {
return $this;
}
$filters = explode(',',$filter);
$this->selectedOptionsCounter = count($filters);
$collection = $this->getLayer()->getProductCollection();
$noRatingCollection = $collection->getCollectionClone();
$this->_coreRegistry->register('no_rating_coll', $noRatingCollection);
$collection->getSelect()->joinLeft(array('rating'=> 'rating_option_vote_aggregated'),'e.entity_id =rating.entity_pk_value',array("percent"))
->where("rating.store_id = ?", $this->_storeManager->getStore()->getId())
->group('e.entity_id');
foreach($filters as $reqFilter){
list($from,$to) = explode('-', $reqFilter);
$conditionArr[] = new \Zend_Db_Expr("rating.percent BETWEEN ".$from." AND ".$to);
}
$condString = '';
foreach($conditionArr as $condition) {
$condString .= " {$condition} OR";
}
$collection->getSelect()->where(substr($condString, 0, -2));
foreach($filters as $reqFilter) {
$state = $this->_createItem($this->getLabelHtml($reqFilter), $reqFilter)
->setVar($this->_requestVar);
$this->getLayer()->getState()->addFilter($state);
}
$collection->getSize();
return $this;
}
/**
* @return \Magento\Framework\Phrase|string
*/
public function getName()
{
$name = ($this->_wpHelper->getRatingFilterName()) ? $this->_wpHelper->getRatingFilterName() : 'Rating';
return __($name);
}
/**
* Get data array for building attribute filter items
*
* @throws \Magento\Framework\Exception\LocalizedException
* @return array
*/
protected function _getItemsData()
{
$collection = $this->_coreRegistry->registry('no_rating_coll');
if (!$this->_wpHelper->isRatingFilterMultiselect() && isset($collection) ) {
return [];
}
$facets = array(
'0-20' => $this->_getRatingLabelHtml(1),
'21-40' => $this->_getRatingLabelHtml(2),
'41-60' => $this->_getRatingLabelHtml(3),
'61-80' => $this->_getRatingLabelHtml(4),
'81-100' => $this->_getRatingLabelHtml(5),
);
if (count($facets) > 1) { // two range minimum
$i=1;
foreach ($facets as $key => $label) {
if (!$collection) {
$collection = $this->getLayer()->getProductCollection();
}
$clonedCollection = clone $collection;
$count = $this->prepareData($key, $clonedCollection, $i);
$i++;
if($count > 0) {
$this->itemDataBuilder->addItemData(
$label,
$key,
$count
);
}
}
}
return $this->itemDataBuilder->build();
}
/**
* @param string $key
* @param int $count
* @return array
*/
private function prepareData($filter,$collection,$i)
{
$filter = explode('-', $filter);
list($from, $to) = $filter;
$collection->clear();
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$collection->getSelect()->joinLeft(array('rating'.$i=> 'rating_option_vote_aggregated'),'e.entity_id =rating'.$i.'.entity_pk_value',array("percent"))
->where("rating".$i.".percent between ".$from." and ".$to)
->where("rating".$i.".store_id = ?", $this->_storeManager->getStore()->getId())
->group('e.entity_id');
return $collection->getSize();
}
/**
* @param $countStars
* @return string
*/
protected function _getRatingLabelHtml($countStars)
{
$html = '<div class="rating-summary" style="display: inline-block;margin-top: -5px;">
<div class="rating-result" title="up to '.$countStars*20 .'%"">
<span style="width:'.$countStars*20 .'%"></span>
</div>
</div>';
return $html;
}
/**
* @return int
*/
public function getSelectedOptionsCounter()
{
return $this->selectedOptionsCounter;
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel;
/**
* Class AttributeOptions
* @package WeltPixel\LayeredNavigation\Model\ResourceModel
*/
class AttributeOptions extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* @var array
*/
protected $loadedAttributes = [];
/**
* AttributeOptions constructor.
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context
)
{
parent::__construct($context);
}
protected function _construct()
{
$this->_init('weltpixel_ln_attribute_options', 'id');
}
/**
* Load Attribute display option by attribute_id & store_id
*
* @param \WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
* @param $attributeId
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function loadDisplayOptionsByAttribute(
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions,
$attributeId
) {
if (isset($this->loadedAttributes[$attributeId])) {
$attributeOptions->setData($this->loadedAttributes[$attributeId]->getData());
return $this;
}
$connection = $this->getConnection();
$bind = [
'attribute_id' => $attributeId
];
$select = $connection->select()->from(
$this->getMainTable(),
[$this->getIdFieldName()]
)->where(
'attribute_id = :attribute_id'
);
$lineId = $connection->fetchOne($select, $bind);
if ($lineId) {
$this->load($attributeOptions, $lineId);
} else {
$attributeOptions->setData([]);
}
$this->loadedAttributes[$attributeId] = clone $attributeOptions;
}
}
@@ -0,0 +1,31 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\AttributeOptions;
/**
* Class Collection
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\AttributeOptions
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
protected $_idFieldName = 'id';
protected $_eventPrefix = 'weltpixel_ln_atribute_options_collection';
protected $_eventObject = 'attribute_options_collection';
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('WeltPixel\LayeredNavigation\Model\AttributeOptions', 'WeltPixel\LayeredNavigation\Model\ResourceModel\AttributeOptions');
}
}
@@ -0,0 +1,587 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext;
use Magento\CatalogSearch\Model\Search\RequestGenerator;
use Magento\Framework\Api\Search\SearchResultFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DB\Select;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\StateException;
use Magento\Framework\Search\Adapter\Mysql\TemporaryStorage;
use Magento\Framework\Search\Request\EmptyRequestDataException;
use Magento\Store\Model\ScopeInterface;
use Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
/**
* Class Collection
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext
*/
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
{
/** @var \WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection|null Clone collection */
public $collectionClone = null;
/** @var string */
private $queryText;
/** @var string|null */
private $order = null;
/** @var string */
private $searchRequestName;
/** @var \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory */
private $temporaryStorageFactory;
/** @var \Magento\Search\Api\SearchInterface */
private $search;
/** @var \WeltPixel\LayeredNavigation\Model\ResourceModel\Search\SearchCriteriaBuilder */
private $searchCriteriaBuilder;
/** @var \Magento\Framework\Api\Search\SearchResultInterface */
private $searchResult;
/** @var \Magento\Framework\Api\FilterBuilder */
private $filterBuilder;
/* @var \Magento\Framework\App\Config\ScopeConfigInterface */
protected $_scopeConfig;
/** @var \Magento\Framework\App\ProductMetadataInterface */
protected $_productMetadata;
/** @var */
protected $_categoryId;
/** @var */
protected $_isTwoOne;
/**
* @var SearchResultFactory
*/
protected $searchResultFactory;
/**
* Collection constructor.
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Framework\App\ResourceConnection $resource
* @param \Magento\Eav\Model\EntityFactory $eavEntityFactory
* @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory
* @param \Magento\Catalog\Model\ResourceModel\Url $catalogUrl
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Customer\Api\GroupManagementInterface $groupManagement
* @param \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory $temporaryStorageFactory
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
* @param string $searchRequestName
* @param SearchResultFactory|null $searchResultFactory
*/
public function __construct(
\Magento\Framework\Data\Collection\EntityFactory $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Eav\Model\Config $eavConfig,
\Magento\Framework\App\ResourceConnection $resource,
\Magento\Eav\Model\EntityFactory $eavEntityFactory,
\Magento\Catalog\Model\ResourceModel\Helper $resourceHelper,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Catalog\Model\Product\OptionFactory $productOptionFactory,
\Magento\Catalog\Model\ResourceModel\Url $catalogUrl,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Customer\Model\Session $customerSession,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Customer\Api\GroupManagementInterface $groupManagement,
\Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory $temporaryStorageFactory,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
$searchRequestName = 'catalog_view_container',
?SearchResultFactory $searchResultFactory = null
)
{
$this->searchResultFactory = $searchResultFactory ?? ObjectManager::getInstance()->get(SearchResultFactory::class);
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$eavConfig,
$resource,
$eavEntityFactory,
$resourceHelper,
$universalFactory,
$storeManager,
$moduleManager,
$catalogProductFlatState,
$scopeConfig,
$productOptionFactory,
$catalogUrl,
$localeDate,
$customerSession,
$dateTime,
$groupManagement,
$connection
);
$this->temporaryStorageFactory = $temporaryStorageFactory;
$this->searchRequestName = $searchRequestName;
$this->_scopeConfig = $scopeConfig;
$this->_productMetadata = $productMetadata;
$this->_isMTwoOneVersion();
}
/**
* WeltPixel LayeredNavigation Clone collection
*
* @return \WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection|null
*/
public function getCollectionClone()
{
if ($this->collectionClone === null) {
$this->collectionClone = clone $this;
$this->collectionClone->setSearchCriteriaBuilder($this->searchCriteriaBuilder->cloneObject());
}
$searchCriterialBuilder = $this->collectionClone->getSearchCriteriaBuilder()->cloneObject();
/** @var \WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection $collectionClone */
$collectionClone = clone $this->collectionClone;
$collectionClone->setSearchCriteriaBuilder($searchCriterialBuilder);
return $collectionClone;
}
/**
* WeltPixel LayeredNavigation Add multi-filter categories
*
* @param $categories
* @return $this
*/
public function addLayerCategoryFilter($categories)
{
$this->addFieldToFilter('category_ids', implode(',', $categories));
return $this;
}
/**
* WeltPixel LayeredNavigation remove filter to load option item data
*
* @param $attributeCode
* @return $this
*/
public function removeAttributeSearch($attributeCode)
{
if (is_array($attributeCode)) {
foreach ($attributeCode as $attCode) {
$this->searchCriteriaBuilder->removeFilter($attCode);
}
} else {
$this->searchCriteriaBuilder->removeFilter($attributeCode);
}
$this->_isFiltersRendered = false;
return $this->loadWithFilter();
}
/**
* WeltPixel LayeredNavigation Get attribute condition sql
*
* @param $attribute
* @param $condition
* @param string $joinType
* @return string
*/
public function getAttributeConditionSql($attribute, $condition, $joinType = 'inner')
{
return $this->_getAttributeConditionSql($attribute, $condition, $joinType);
}
/**
* WeltPixel LayeredNavigation Reset Total records
*
* @return $this
*/
public function resetTotalRecords($collectionCount = null)
{
$this->_totalRecords = $collectionCount;
return $this;
}
/**
* @return int|void
*/
public function getSize() {
return sizeof($this->getAllIds());
}
/**
* @return \Magento\Search\Api\SearchInterface|mixed
*/
private function getSearch()
{
if ($this->search === null) {
$this->search = ObjectManager::getInstance()->get('\Magento\Search\Api\SearchInterface');
}
return $this->search;
}
/**
* @param \Magento\Search\Api\SearchInterface $object
*/
public function setSearch(\Magento\Search\Api\SearchInterface $object)
{
$this->search = $object;
}
/**
* @return mixed|\WeltPixel\LayeredNavigation\Model\ResourceModel\Search\SearchCriteriaBuilder
*/
public function getSearchCriteriaBuilder()
{
if ($this->searchCriteriaBuilder === null) {
$this->searchCriteriaBuilder = ObjectManager::getInstance()
->get('\WeltPixel\LayeredNavigation\Model\ResourceModel\Search\SearchCriteriaBuilder');
}
return $this->searchCriteriaBuilder;
}
/**
* @param \WeltPixel\LayeredNavigation\Model\ResourceModel\Search\SearchCriteriaBuilder $object
*/
public function setSearchCriteriaBuilder(\WeltPixel\LayeredNavigation\Model\ResourceModel\Search\SearchCriteriaBuilder $object)
{
$this->searchCriteriaBuilder = $object;
}
/**
* @return \Magento\Framework\Api\FilterBuilder|mixed
*/
private function getFilterBuilder()
{
if ($this->filterBuilder === null) {
$this->filterBuilder = ObjectManager::getInstance()->get('\Magento\Framework\Api\FilterBuilder');
}
return $this->filterBuilder;
}
/**
* @param \Magento\Framework\Api\FilterBuilder $object
*/
public function setFilterBuilder(\Magento\Framework\Api\FilterBuilder $object)
{
$this->filterBuilder = $object;
}
/**
* Apply attribute filter to facet collection
*
* @param string $field
* @param null $condition
* @return $this
*/
public function addFieldToFilter($field, $condition = null)
{
if ($this->searchResult !== null) {
throw new \RuntimeException('Illegal state');
}
$this->getSearchCriteriaBuilder();
$this->getFilterBuilder();
if (is_array($condition) && $this->_isElasticOrOpenSearchEngine()) {
$this->filterBuilder->setField($field);
$this->filterBuilder->setValue($condition);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
} elseif (!is_array($condition) || !in_array(key($condition), ['from', 'to'])) {
$this->filterBuilder->setField($field);
$this->filterBuilder->setValue($condition);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
} else {
if (!empty($condition['from'])) {
$this->filterBuilder->setField("{$field}.from");
$this->filterBuilder->setValue($condition['from']);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
}
if (!empty($condition['to'])) {
$this->filterBuilder->setField("{$field}.to");
$this->filterBuilder->setValue($condition['to']);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
}
}
return $this;
}
/**
* Add search query filter
*
* @param string $query
* @return $this
*/
public function addSearchFilter($query)
{
$this->queryText = trim($this->queryText . ' ' . $query);
return $this;
}
/**
* @inheritdoc
*/
protected function _renderFiltersBefore()
{
$this->getCollectionClone();
$this->getSearchCriteriaBuilder();
$this->getFilterBuilder();
$this->getSearch();
if ($this->queryText) {
$this->filterBuilder->setField('search_term');
$this->filterBuilder->setValue($this->queryText);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
}
$priceRangeCalculation = $this->_scopeConfig->getValue(
\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
if ($priceRangeCalculation) {
$this->filterBuilder->setField('price_dynamic_algorithm');
$this->filterBuilder->setValue($priceRangeCalculation);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
}
if ($this->_isTwoOne) {
$this->filterBuilder->setField('category_ids');
$this->filterBuilder->setValue($this->_categoryId);
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
}
$searchCriteria = $this->searchCriteriaBuilder->create();
$searchCriteria->setRequestName($this->searchRequestName);
if ($this->_isElasticOrOpenSearchEngine()) {
if ($this->order && isset($this->order['field'])) {
$fieldValue = explode("~", $this->order['field']);
} else {
$fieldValue = [];
$fieldValue[0]=null;
}
if (!$fieldValue[0]) {
$searchCriteria->setSortOrders([
'entity_id' => 'DESC'
]);
} else {
$searchCriteria->setSortOrders([
$fieldValue[0] => $this->order['dir']
]);
}
}
try {
$this->searchResult = $this->getSearch()->search($searchCriteria);
} catch (EmptyRequestDataException $e) {
/** @var \Magento\Framework\Api\Search\SearchResultInterface $searchResult */
$this->searchResult = $this->searchResultFactory->create()->setItems([]);
} catch (\Exception $e) {
throw new LocalizedException(__('Something went wrong, check and test your Search Engine configurations, reindex catalog and clear cache. Thrown error: %1', $e->getMessage()));
}
try {
$temporaryStorage = $this->temporaryStorageFactory->create();
$table = $temporaryStorage->storeDocuments($this->searchResult->getItems());
$this->getSelect()->joinInner(
[
'search_result' => $table->getName(),
],
'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID,
[]
);
if ($this->order && 'relevance' === $this->order['field']) {
$this->getSelect()->order('search_result.' . TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
}
} catch (\Exception $ex) {
$this->_logger->error($ex->getMessage());
}
parent::_renderFiltersBefore();
}
/**
* @return $this
*/
protected function _renderFilters()
{
$this->_filters = [];
return parent::_renderFilters();
}
/**
* Set Order field
*
* @param string $attribute
* @param string $dir
* @return $this
*/
public function setOrder($attribute, $dir = Select::SQL_DESC)
{
$this->order = ['field' => $attribute, 'dir' => $dir];
if ($attribute != 'relevance') {
parent::setOrder($attribute, $dir);
}
return $this;
}
/**
* Stub method for compatibility with other search engines
*
* @return $this
*/
public function setGeneralDefaultQuery()
{
return $this;
}
/**
* Return field faceted data from faceted search result
*
* @param string $field
* @return array
* @throws StateException
*/
public function getFacetedData($field)
{
$this->_renderFilters();
$result = [];
$aggregations = $this->searchResult->getAggregations();
if (null !== $aggregations) {
$bucket = $aggregations->getBucket($field . RequestGenerator::BUCKET_SUFFIX);
if ($bucket) {
foreach ($bucket->getValues() as $value) {
$metrics = $value->getMetrics();
$result[$metrics['value']] = $metrics;
}
} else {
throw new StateException(__('Bucket does not exist'));
}
}
return $result;
}
/**
* Specify category filter for product collection
*
* @param \Magento\Catalog\Model\Category $category
* @return $this
*/
public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
{
$this->_categoryId = $category->getId();
$this->addFieldToFilter('category_ids', $category->getId());
return parent::addCategoryFilter($category);
}
/**
* Set product visibility filter for enabled products
*
* @param array $visibility
* @return $this
*/
public function setVisibility($visibility)
{
$this->addFieldToFilter('visibility', $visibility);
return parent::setVisibility($visibility);
}
/**
* Check the engine provider is 'elasticsearch'
* @deprecated
*
* @return bool
*/
protected function _isElasticSearchEngine()
{
$currentEngine = $this->_scopeConfig->getValue(EngineInterface::CONFIG_ENGINE_PATH, ScopeInterface::SCOPE_STORE);
if ($currentEngine == 'elasticsearch' || $currentEngine == 'elasticsearch5' || $currentEngine == 'elasticsearch6'
|| $currentEngine == 'elasticsearch7' || $currentEngine == 'elasticsearch8') {
return true;
}
return false;
}
/**
* Check the engine provider is 'elasticsearch' or 'opensearch'
*
* @return bool
*/
protected function _isElasticOrOpenSearchEngine()
{
$currentEngine = $this->_scopeConfig->getValue(EngineInterface::CONFIG_ENGINE_PATH, ScopeInterface::SCOPE_STORE);
if ($currentEngine == 'elasticsearch' || $currentEngine == 'elasticsearch5' || $currentEngine == 'elasticsearch6'
|| $currentEngine == 'elasticsearch7' || $currentEngine == 'opensearch') {
return true;
}
return false;
}
/**
* check magento version
* @return bool
*/
protected function _isMTwoOneVersion()
{
$version = $this->_productMetadata->getVersion();
$pos = strpos($version, '2.1');
if ($pos === false) {
$this->_isTwoOne = false;
} else {
$this->_isTwoOne = true;
}
return $this->_isTwoOne;
}
}
@@ -0,0 +1,61 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Layer\Filter;
/**
* Class Attribute
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Layer\Filter
*/
class Attribute extends \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute
{
/**
* Retrieve array with products counts per attribute option
*
* @param \Magento\Catalog\Model\Layer\Filter\FilterInterface $filter
* @throws \Magento\Framework\Exception\LocalizedException
* @return array
*/
public function getCount(\Magento\Catalog\Model\Layer\Filter\FilterInterface $filter)
{
// clone select from collection with filters
$layer = $filter->getLayer();
if($layer instanceof \Magento\Catalog\Model\Layer\Search) {
$collectionSelect = $layer->getProductCollection()->getSelect();
} else {
$collectionSelect = $layer->getCurrentCategory()->getProductCollection()->getSelect();
}
$select = clone $collectionSelect;
// reset columns, order and limitation conditions
$select->reset(\Magento\Framework\DB\Select::COLUMNS);
$select->reset(\Magento\Framework\DB\Select::ORDER);
$select->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
$select->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
$connection = $this->getConnection();
$attribute = $filter->getAttributeModel();
$tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
$conditions = [
"{$tableAlias}.entity_id = e.entity_id",
$connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
$connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()),
];
$select->join(
[$tableAlias => $this->getMainTable()],
join(' AND ', $conditions),
['value', 'count' => new \Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")]
)->group(
"{$tableAlias}.value"
);
return $connection->fetchPairs($select);
}
}
@@ -0,0 +1,19 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Search;
use Magento\Framework\Api\Search\FilterGroup as SourceFilterGroup;
/**
* Class FilterGroup
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Search
*/
class FilterGroup extends SourceFilterGroup
{
}
@@ -0,0 +1,92 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Search;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\ObjectFactory;
use Magento\Framework\Api\Search\FilterGroup as SourceFilterGroup;
use Magento\Framework\Api\Search\FilterGroupBuilder as SourceFilterGroupBuilder;
use Magento\Framework\App\RequestInterface;
/**
* Class FilterGroupBuilder
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Search
*/
class FilterGroupBuilder extends SourceFilterGroupBuilder
{
/** @var \Magento\Framework\App\RequestInterface */
protected $_request;
/**
* FilterGroupBuilder constructor.
* @param \Magento\Framework\Api\ObjectFactory $objectFactory
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
* @param \Magento\Framework\App\RequestInterface $request
*/
public function __construct(
ObjectFactory $objectFactory,
FilterBuilder $filterBuilder,
RequestInterface $request
)
{
parent::__construct($objectFactory, $filterBuilder);
$this->_request = $request;
}
/**
* @return FilterGroupBuilder
*/
public function cloneObject()
{
$cloneObject = clone $this;
$cloneObject->setFilterBuilder(clone $this->_filterBuilder);
return $cloneObject;
}
/**
* @param $filterBuilder
*/
public function setFilterBuilder($filterBuilder)
{
$this->_filterBuilder = $filterBuilder;
}
/**
* @param $attributeCode
*
* @return $this
*/
public function removeFilter($attributeCode)
{
if (isset($this->data[SourceFilterGroup::FILTERS])) {
foreach ($this->data[SourceFilterGroup::FILTERS] as $key => $filter) {
if ($filter->getField() == $attributeCode) {
if (($attributeCode == 'category_ids') && ($filter->getValue() == $this->_request->getParam('id'))) {
continue;
}
unset($this->data[SourceFilterGroup::FILTERS][$key]);
}
}
}
return $this;
}
/**
* Return the Data type class name
*
* @return string
*/
protected function _getDataObjectType()
{
return 'Magento\Framework\Api\Search\FilterGroup';
}
}
@@ -0,0 +1,19 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Search;
use Magento\Framework\Api\Search\SearchCriteria as SourceSearchCriteria;
/**
* Class SearchCriteria
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Search
*/
class SearchCriteria extends SourceSearchCriteria
{
}
@@ -0,0 +1,73 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Model\ResourceModel\Search;
use Magento\Framework\Api\ObjectFactory;
use Magento\Framework\Api\Search\SearchCriteriaBuilder as SourceSearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
/**
* Class SearchCriteriaBuilder
* @package WeltPixel\LayeredNavigation\Model\ResourceModel\Search
*/
class SearchCriteriaBuilder extends SourceSearchCriteriaBuilder
{
/**
* @param ObjectFactory $objectFactory
* @param FilterGroupBuilder $filterGroupBuilder
* @param SortOrderBuilder $sortOrderBuilder
*/
public function __construct(
ObjectFactory $objectFactory,
FilterGroupBuilder $filterGroupBuilder,
SortOrderBuilder $sortOrderBuilder
)
{
parent::__construct($objectFactory, $filterGroupBuilder, $sortOrderBuilder);
}
/**
* @param $attributeCode
*
* @return $this
*/
public function removeFilter($attributeCode)
{
$this->filterGroupBuilder->removeFilter($attributeCode);
return $this;
}
/**
* @return SearchCriteriaBuilder
*/
public function cloneObject()
{
$cloneObject = clone $this;
$cloneObject->setFilterGroupBuilder($this->filterGroupBuilder->cloneObject());
return $cloneObject;
}
/**
* @param $filterGroupBuilder
*/
public function setFilterGroupBuilder($filterGroupBuilder)
{
$this->filterGroupBuilder = $filterGroupBuilder;
}
/**
* @return string
*/
protected function _getDataObjectType()
{
return 'Magento\Framework\Api\Search\SearchCriteria';
}
}
@@ -0,0 +1,803 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Observer\Edit\Tab\Front;
use Magento\Config\Model\Config\Source;
use Magento\Framework\Module\Manager;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\Http;
use WeltPixel\LayeredNavigation\Model\AttributeOptions;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Helper\Category;
/**
* Class WpProductAttributeFormBuildFrontTabObserver
* @package WeltPixel\LayeredNavigation\Observer\Edit\Tab\Front
*/
class WpProductAttributeFormBuildFrontTabObserver implements ObserverInterface
{
/**
* @var \Magento\Config\Model\Config\Source\Yesno
*/
protected $optionList;
/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;
/**
* @var Http
*/
protected $_request;
/**
* @var AttributeOptions
*/
protected $_wpModel;
protected $_wpAttributeObj = false;
/**
* @var Attribute
*/
protected $_attributeModel;
/**
* @var \Magento\Catalog\Block\Adminhtml\Category\Tree
*/
protected $adminCategoryTree;
/**
* @var \Magento\Catalog\Model\Indexer\Category\Flat\State
*/
protected $categoryFlatConfig;
/**
* WpProductAttributeFormBuildFrontTabObserver constructor.
* @param Manager $moduleManager
* @param Source\Yesno $optionList
* @param Http $request
* @param AttributeOptions $wpModel
* @param Attribute $attributeModel
* @param \Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState
* @param \Magento\Catalog\Block\Adminhtml\Category\Tree $adminCategoryTree
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function __construct(
Manager $moduleManager,
Source\Yesno $optionList,
Http $request,
AttributeOptions $wpModel,
Attribute $attributeModel,
\Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState,
\Magento\Catalog\Block\Adminhtml\Category\Tree $adminCategoryTree
)
{
$this->optionList = $optionList;
$this->moduleManager = $moduleManager;
$this->_request = $request;
$this->_wpModel = $wpModel;
$this->_attributeModel = $attributeModel;
$this->categoryFlatConfig = $categoryFlatState;
$this->adminCategoryTree = $adminCategoryTree;
$this->_getWpAttributeOptionValues();
}
/**
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->moduleManager->isOutputEnabled('WeltPixel_LayeredNavigation')) {
return;
}
$isSwatchAttr = $this->_isSwatchAttr();
$swatchComment = $isSwatchAttr ? '<br/>This setting can not be used with swatch attribute types.' : '';
/** @var \Magento\Framework\Data\Form\AbstractForm $form */
$form = $observer->getForm();
$fieldset = $form->addFieldset(
'wp_front_fieldset',
['legend' => __('WeltPixel Layered Navigation Properties'), 'collapsable' => false]
);
$field = '';
if(!$isSwatchAttr) {
$value = [
['value' => 0, 'label' => __('Closed')],
['value' => 1, 'label' => __('Fully Opened')],
['value' => 2, 'label' => __('Expandable')],
];
} else {
$value = [
['value' => 0, 'label' => __('Closed')],
['value' => 1, 'label' => __('Fully Opened')],
];
}
$fieldset->addField(
'wp_display_options',
'select',
[
'name' => 'wp_display_options',
'label' => __("Show Attribute Options as"),
'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
'note' => __('[Closed] option not applicable on [Slide Down] Sidebar Style. <br/> The [Closed] option is recommended if you’re using the Horizontal Design for the Layered Navigation'),
'values' => $value,
'value' => $this->_getDisplayOption(),
]
);
$field = $fieldset->addField(
'wp_visible_options',
'text',
[
'name' => 'wp_visible_options',
'label' => __("Initial Number of Visible Options"),
'value' => $this->_getVisibleOptions(),
'title' => __('The number of attribute option(s) that will be initially visible. Can be used only with Show Attribute Options as - Expandable.'),
'note' => __('The number of attribute option(s) that will be initially visible. Can be used only with Show Attribute Options as - Expandable. %1', $swatchComment)
]
);
$field = $fieldset->addField(
'wp_visible_options_step',
'select',
[
'name' => 'wp_visible_options_step',
'label' => __("Expandable items behaviour"),
'values' => [
['value' => 99, 'label' => __('All')],
['value' => 5, 'label' => __('Show 5 more')],
['value' => 10, 'label' => __('Show 10 more')],
['value' => 15, 'label' => __('Show 15 more')],
],
'value' => $this->_getVisibleOptions(),
'title' => __('Select the number of attribute option(s) to show/hide when using Expand feature.<br> Can be used only with Show Attribute Options as - Expandable.'),
'note' => __('Select the number of attribute option(s) to show/hide when using Expand feature.<br> Can be used only with Show Attribute Options as - Expandable. %1', $swatchComment)
]
);
$fieldset->addField(
'wp_is_multiselect',
'select',
[
'name' => 'wp_is_multiselect',
'label' => __("Enable Multiselect"),
'value' => $this->_getIsMultiselect(),
'values' => [
['value' => 0, 'label' => __('No')],
['value' => 1, 'label' => __('Yes')],
],
'title' => __('Allow to filter multiple options from the same attribute.'),
'note' => __('Allow to filter multiple options from the same attribute.')
]
);
$fieldset->addField(
'wp_keep_open_after_filter',
'select',
[
'name' => 'wp_keep_open_after_filter',
'label' => __("Keep attribute opened after filterings"),
'value' => $this->_getKeepOpenAfterFilter(),
'values' => [
['value' => 0, 'label' => __('No')],
['value' => 1, 'label' => __('Yes')],
],
'title' => __('Allow to keep attribute open after filtering.'),
'note' => __('Allow to keep attribute open after filtering.')
]
);
$fieldset->addField(
'wp_show_quantity',
'select',
[
'name' => 'wp_show_quantity',
'label' => __("Show Item Counter"),
'value' => $this->_getShowQuantity(),
'values' => [
['value' => 0, 'label' => __('No')],
['value' => 1, 'label' => __('Yes')],
],
'title' => __('Show item counter next to the current attribute options.'),
'note' => __('Show item counter next to the current attribute options. %1', $swatchComment)
]
);
$fieldset->addField(
'wp_sort_by',
'select',
[
'name' => 'wp_sort_by',
'label' => __("Sort By"),
'value' => $this->_getSortBy(),
'values' => [
['value' => 1, 'label' => __('Position')],
['value' => 2, 'label' => __('Name')],
],
'title' => __('Select the sorting of the current attribute options.'),
'note' => __('Select the sorting of the current attribute options. %1', $swatchComment)
]
);
if(!$isSwatchAttr) {
$fieldset->addField(
'wp_instant_search',
'select',
[
'name' => 'wp_instant_search',
'label' => __("Enable options filter on Desktop"),
'value' => $this->_getInstantSearch(),
'values' => [
['value' => 0, 'label' => __('No')],
['value' => 1, 'label' => __('Yes')],
],
'title' => __('Enable search functionality for attribute options on desktop.'),
'note' => __('Enable search functionality for attribute options on desktop. %1', $swatchComment)
]
);
$fieldset->addField(
'wp_instant_search_mobile',
'select',
[
'name' => 'wp_instant_search_mobile',
'label' => __("Enable options filter on Mobile"),
'value' => $this->_getInstantSearchMobile(),
'values' => [
['value' => 0, 'label' => __('No')],
['value' => 1, 'label' => __('Yes')],
],
'title' => __('Enable search functionality for attribute options on mobile.'),
'note' => __('Enable search functionality for attribute options on mobile. %1', $swatchComment)
]
);
}
$fieldset->addField(
'wp_category_visibility',
'select',
[
'name' => 'wp_category_visibility',
'label' => __("Category Visibility"),
'value' => $this->_getCategoryVisibility(),
'values' => [
['value' => 0, 'label' => __('Visible in all categories')],
['value' => 1, 'label' => __('Visible only in the following categories')],
['value' => 2, 'label' => __('Not visible in the following categories')],
],
'title' => __('Select visibility behaviour in categories for the current attribute.'),
'note' => __('Select visibility behaviour in categories for the current attribute.')
]
);
$fieldset->addField(
'wp_category_ids',
'multiselect',
[
'name' => 'wp_category_ids[]',
'label' => __("Select Categories"),
'value' => $this->_getCategoryIds(),
'values' => $this->categoriesToOptionArray(),
'title' => __('Select categories.'),
'note' => __('Select categories.')
]
);
if ($field) {
$field->setAfterElementHtml(
"<script>
//<![CDATA[
require(['jquery', 'jquery/ui'], function($){
var acceptedTypeArray = ['select','multiselect','price','swatch_visual','swatch_text'],
wpDisplayOptionEl = $('#wp_display_options'),
wpVisibleOptionsEl = $('#wp_visible_options'),
wpVisibleOptionsStepEl = $('#wp_visible_options_step'),
wpIsMultiselectEl = $('#wp_is_multiselect'),
wpKeepAttributeOpenEl = $('#wp_keep_open_after_filter'),
wpKeepAttributeOpenRow = $('.field-wp_keep_open_after_filter'),
wpShowQuantityEl = $('#wp_show_quantity'),
wpSortByEl = $('#wp_sort_by'),
wpIsD = $('#wp_instant_search'),
wpIsM = $('#wp_instant_search_mobile'),
mageFrontendInpEl = $('#frontend_input'),
categoryVisibilityEl = $('#wp_category_visibility'),
categoryIdsElement = $('#wp_category_ids'),
categoryIdsEl = $('.field-wp_category_ids'),
displayOpt = '" . $this->_getDisplayOption() . "',
visibleOpt = '" . $this->_getVisibleOptions() . "',
visibleOptStep = '" . $this->_getVisibleOptionsStep() . "',
isMultiselect = '" . $this->_getIsMultiselect() . "',
isAttributeOpen = '" . $this->_getKeepOpenAfterFilter() . "',
showQuantity = '" . $this->_getShowQuantity() . "',
sortBy = '" . $this->_getSortBy() . "';
instantSearchD = '" . $this->_getInstantSearch() . "';
instantSearchM = '" . $this->_getInstantSearchMobile() . "';
categoryVisibility = '".$this->_getCategoryVisibility()."';
categoryIds = '".$this->_getCategoryIds()."';
categoryIdsArray = categoryIds.split(',');
isSwatch = '".$isSwatchAttr."';
wpDisplayOptionEl.val(displayOpt);
wpVisibleOptionsEl.val(visibleOpt);
wpVisibleOptionsStepEl.val(visibleOptStep);
wpIsMultiselectEl.val(isMultiselect);
wpKeepAttributeOpenEl.val(isAttributeOpen);
wpShowQuantityEl.val(showQuantity);
wpSortByEl.val(sortBy);
wpIsD.val(instantSearchD);
wpIsM.val(instantSearchM);
categoryVisibilityEl.val(categoryVisibility);
categoryIdsElement.val(categoryIdsArray);
setWpVisibility();
wpIsMultiselectEl.change(function() {
if(wpIsMultiselectEl.val() != 0) {
wpKeepAttributeOpenRow.show();
} else {
wpKeepAttributeOpenRow.hide();
}
});
categoryVisibilityEl.change(function() {
if(categoryVisibilityEl.val() != 0) {
categoryIdsEl.show();
} else {
categoryIdsEl.hide();
}
})
wpDisplayOptionEl.change(function(){
if($(this).val() == 2) {
enableElement(wpVisibleOptionsEl);
enableElement(wpVisibleOptionsStepEl);
wpVisibleOptionsEl.val(visibleOpt);
wpVisibleOptionsStepEl.val(visibleOptStep);
} else {
wpVisibleOptionsEl.val(99);
wpVisibleOptionsStepEl.val(99);
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
}
});
mageFrontendInpEl.change(function(){
var selVal = $(this).val();
if($.inArray(selVal, acceptedTypeArray) !== -1) {
enableElement(wpDisplayOptionEl);
enableElement(wpIsMultiselectEl);
enableElement(wpShowQuantityEl);
enableElement(wpSortByEl);
if(wpDisplayOptionEl.val() == 2){
enableElement(wpVisibleOptionsEl);
enableElement(wpVisibleOptionsStepEl);
} else {
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
}
} else {
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
disableElement(wpDisplayOptionEl);
disableElement(wpIsMultiselectEl);
disableElement(wpShowQuantityEl);
disableElement(wpSortByEl);
}
});
/**
* set wp fields property(disabled)
*/
function setWpVisibility(){
var elVal = mageFrontendInpEl.val();
if(categoryVisibilityEl.val() != 0) {
categoryIdsEl.show();
} else {
categoryIdsEl.hide();
}
if(wpIsMultiselectEl.val() != 0) {
wpKeepAttributeOpenRow.show();
} else {
wpKeepAttributeOpenRow.hide();
}
if($.inArray(elVal, acceptedTypeArray) !== -1) {
enableElement(wpDisplayOptionEl);
enableElement(wpIsMultiselectEl);
enableElement(wpShowQuantityEl);
enableElement(wpSortByEl);
} else {
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
disableElement(wpDisplayOptionEl);
disableElement(wpIsMultiselectEl);
disableElement(wpShowQuantityEl);
disableElement(wpSortByEl);
}
if(wpDisplayOptionEl.val() != 2){
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
}
if(isSwatch) {
disableElement(wpVisibleOptionsEl);
disableElement(wpVisibleOptionsStepEl);
disableElement(wpShowQuantityEl);
disableElement(wpSortByEl);
disableElement(wpIsD);
disableElement(wpIsM);
disableElement(wpIsM);
}
}
/**
* set element as disabled
* @param element
*/
function disableElement(element) {
element.prop('disabled', true);
}
/**
* remove 'disabled' attribute from element
* @param element
*/
function enableElement(element) {
element.removeAttr('disabled');
}
});
//]]>
</script>"
);
}
}
protected function _isSwatchAttr() {
$attributeId = $this->_request->getParam('attribute_id');
if ($attributeId) {
$attr = $this->_attributeModel->load($attributeId);
if(!$attr->getAdditionalData()) {
return false;
}
$addititonalData = $attr->getAdditionalData();
$attrData = json_decode($addititonalData, true);
if(isset($attrData['swatch_input_type'])) {
return true;
}
return true;
}
return false;
}
/**
* Check if value is a serialized string
*
* @param string $value
* @return boolean
*/
private function isSerialized($value)
{
return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value);
}
/**
* @return $this|bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _getWpAttributeOptionValues()
{
$attributeId = $this->_request->getParam('attribute_id');
if ($attributeId) {
$this->_wpAttributeObj = $this->_wpModel->getDisplayOptionsByAttribute($attributeId);
}
return $this;
}
/**
* Get attribute 'display_option' value
* @return int
*/
protected function _getDisplayOption()
{
$val = AttributeOptions::DISPLAY_OPTION_DEF_VAL;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getDisplayOption();
}
}
return $val;
}
/**
* Get attribute 'visible_options' value
* @return int
*/
protected function _getVisibleOptions()
{
$val = '';
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getVisibleOptions();
}
}
return $val;
}
/**
* Get attribute 'visible_options' value
* @return int
*/
protected function _getVisibleOptionsStep()
{
$val = '';
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getVisibleOptionsStep();
}
}
return $val;
}
/**
* Get attribute 'is_multiselect' value
* @return int
*/
protected function _getIsMultiselect()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getIsMultiselect();
}
}
return $val;
}
/**
* Get attribute 'keep_open_after_filter' value
* @return int
*/
protected function _getKeepOpenAfterFilter()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getKeepOpenAfterFilter();
}
}
return $val;
}
/**
* Get attribute 'show_quantity' value
* @return int
*/
protected function _getShowQuantity()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getShowQuantity();
}
}
return $val;
}
/**
* Get attribute 'sort_by' value
* @return int
*/
protected function _getSortBy()
{
$val = 1;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getSortBy();
}
}
return $val;
}
/**
* Get attribute 'instant_search' value
* @return int
*/
protected function _getInstantSearch()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getInstantSearch();
}
}
return $val;
}
/**
* Get attribute 'instant_search_mobile' value
* @return int
*/
protected function _getInstantSearchMobile()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getInstantSearchMobile();
}
}
return $val;
}
/**
* Get attribute 'category_visibility' value
* @return int
*/
protected function _getCategoryVisibility()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getCategoryVisibility();
}
}
return $val;
}
/**
* Get attribute 'category_visibility' value
* @return int
*/
protected function _getCategoryIds()
{
$val = 0;
if($this->_wpAttributeObj) {
if(!empty($this->_wpAttributeObj->getData())) {
$val = $this->_wpAttributeObj->getCategoryIds();
}
}
return $val;
}
/**
* @param array $result
* @param string $prefix
* @param array $category
* @param bool $ignore
*/
protected function recursiveCategories(&$result, $prefix, $category, $ignore = false)
{
if (!$ignore) {
$result[$prefix . $category['id']] = __($category['text']);
$prefix = $prefix . $category['id'] . '_';
}
if (isset($category['children'])) {
foreach ($category['children'] as $categ) {
$this->recursiveCategories($result, $prefix, $categ);
}
}
}
/**
* Get options in "key-value" format
* @return array
*/
public function categoriesArray()
{
$categories = $this->adminCategoryTree->getTree();
$categoryList = [];
foreach ($categories as $category) {
$this->recursiveCategories($categoryList, '', $category, true);
}
return $categoryList;
}
/**
* @return array
*/
public function categoriesToOptionArray()
{
$arr = $this->categoriesArray();
$ret = [];
foreach ($arr as $key => $value)
{
$catIdArr = explode('_', $key);
if(count($catIdArr) == 1) {
$ret[] = [
'value' => $key,
'label' => $value,
'style' => 'font-weight:bold'
];
} elseif(count($catIdArr) == 2) {
$ret[] = [
'value' => $catIdArr[1],
'label' => $value,
'style' => 'padding-left: 25px'
];
} elseif(count($catIdArr) == 3) {
$ret[] = [
'value' => $catIdArr[2],
'label' => $value,
'style' => 'padding-left: 45px'
];
} else {
$ret[] = [
'value' => $catIdArr[3],
'label' => $value,
'style' => 'padding-left: 65px'
];
}
}
return $ret;
}
/**
* @param $category
* @return array
*/
public function getChildCategories($category)
{
if ($this->categoryFlatConfig->isFlatEnabled() && $category->getUseFlatResource()) {
$subcategories = (array)$category->getChildrenNodes();
} else {
$subcategories = $category->getChildren();
}
return $subcategories;
}
}
@@ -0,0 +1,100 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Observer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
/**
* Class RemoveBlocks
* @package WeltPixel\LayeredNavigation\Observer
*/
class RemoveBlocks implements ObserverInterface
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var \Magento\Framework\App\Request\Http
*/
protected $_request;
/**
* RemoveBlocks constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
* @param \Magento\Framework\App\Request\Http $request
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
\Magento\Framework\App\Request\Http $request
) {
$this->_scopeConfig = $scopeConfig;
$this->_wpHelper = $wpHelper;
$this->_request = $request;
}
public function execute(Observer $observer)
{
if($this->_isAdvancedSearchResultPage() || !$this->_wpHelper->isEnabled()) {
return;
}
/** @var \Magento\Framework\View\Layout $layout */
$layout = $observer->getLayout();
$wishlistBlock = $layout->getBlock('wishlist_sidebar');
$compareBlock = $layout->getBlock('catalog.compare.sidebar');
$reorderBlock = $layout->getBlock('sale.reorder.sidebar');
$slideMode = $this->_wpHelper->getSlideMode();
if($wishlistBlock) {
$showWishlistBlock = $this->_wpHelper->showWishlistBlock();
if (!$showWishlistBlock || $slideMode) {
$layout->unsetElement('wishlist_sidebar');
}
}
if($compareBlock) {
$showCompareBlock = $this->_wpHelper->showCompareBlock();
if (!$showCompareBlock || $slideMode) {
$layout->unsetElement('catalog.compare.sidebar');
}
}
if ($reorderBlock) {
$showRecentlyOrderedBlock = $this->_wpHelper->showRecentlyOrderedBlock();
if (!$showRecentlyOrderedBlock || $slideMode) {
$layout->unsetElement('sale.reorder.sidebar');
}
}
}
/**
* @return bool
*/
protected function _isAdvancedSearchResultPage() {
$is = false;
$controller = $this->_request->getControllerName();
$action = $this->_request->getActionName();
$route = $this->_request->getRouteName();
if($route == 'catalogsearch' && $controller == 'advanced' && $action == 'result') {
$is = true;
}
return $is;
}
}
@@ -0,0 +1,39 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Observer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
/**
* Class UpdateBodyClass
* @package WeltPixel\LayeredNavigation\Observer
*/
class UpdateBodyClass implements ObserverInterface
{
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* RemoveBlocks constructor.
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
*/
public function __construct(
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper
) {
$this->_wpHelper = $wpHelper;
}
public function execute(Observer $observer)
{
$this->_wpHelper->updateSliderBodyClass();
}
}
@@ -0,0 +1,95 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Observer;
use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;
/**
* Class WpCatalogAttributeSaveAfterObserver
* @package WeltPixel\LayeredNavigation\Model\Observer
*/
class WpCatalogAttributeSaveAfterObserver implements ObserverInterface
{
/**
* @var array
*/
protected $_lnInputTypes = [
'select',
'multiselect',
'price'
];
/**
* @var \WeltPixel\LayeredNavigation\Model\AttributeOptions
*/
protected $_attributeOptions;
/**
* @param CheckSalesRulesAvailability $checkSalesRulesAvailability
*/
public function __construct(
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
)
{
$this->_attributeOptions = $attributeOptions;
}
/**
* After save attribute
*
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)
{
$attribute = $observer->getEvent()->getAttribute();
$wpAttributeOptions = $this->_attributeOptions->getDisplayOptionsByAttribute($attribute->getAttributeId());
if (in_array($attribute->getFrontendInput(), $this->_lnInputTypes)) {
// insert
if (!$wpAttributeOptions->getId()) {
$categoryIds = (null !== $attribute->getWpCategoryIds() && is_array($attribute->getWpCategoryIds())) ? implode(',',$attribute->getWpCategoryIds()) : '';
$this->_attributeOptions->setAttributeId($attribute->getAttributeId())
->setDisplayOption($attribute->getWpDisplayOptions())
->setVisibleOptions($attribute->getWpVisibleOptions())
->setVisibleOptionsStep($attribute->getWpVisibleOptionsStep())
->setIsMultiselect($attribute->getWpIsMultiselect())
->setKeepOpenAfterFilter($attribute->getWpKeepOpenAfterFilter())
->setShowQuantity($attribute->getWpShowQuantity())
->setSortBy($attribute->getWpSortBy())
->setInstantSearch($attribute->getWpInstantSearch())
->setInstantSearchMobile($attribute->getWpInstantSearchMobile())
->setCategoryVisibility($attribute->getWpCategoryVisibility())
->setCategoryIds($categoryIds)
->save();
} // update
else {
$visibleItems = ($attribute->getWpDisplayOptions() == \WeltPixel\LayeredNavigation\Model\AttributeOptions::DISPLAY_OPTION_OPEN_VAL || $attribute->getWpDisplayOptions() == \WeltPixel\LayeredNavigation\Model\AttributeOptions::DISPLAY_OPTION_DEF_VAL) ? \WeltPixel\LayeredNavigation\Model\AttributeOptions::VISIBLE_OPTIONS_DEF_VAL : $attribute->getWpVisibleOptions();
$visibleItemsStep = (!$attribute->getWpDisplayOptions() == \WeltPixel\LayeredNavigation\Model\AttributeOptions::DISPLAY_OPTION_OPEN_VAL || $attribute->getWpDisplayOptions() == \WeltPixel\LayeredNavigation\Model\AttributeOptions::DISPLAY_OPTION_DEF_VAL) ? \WeltPixel\LayeredNavigation\Model\AttributeOptions::VISIBLE_OPTIONS_STEP_DEF_VAL : $attribute->getWpVisibleOptionsStep();
$categoryIds = (null !== $attribute->getWpCategoryIds() && is_array($attribute->getWpCategoryIds())) ? implode(',',$attribute->getWpCategoryIds()) : '';
$this->_attributeOptions->setId($wpAttributeOptions->getId())
->setDisplayOption($attribute->getWpDisplayOptions())
->setVisibleOptions($visibleItems)
->setVisibleOptionsStep($visibleItemsStep)
->setIsMultiselect($attribute->getWpIsMultiselect())
->setKeepOpenAfterFilter($attribute->getWpKeepOpenAfterFilter())
->setShowQuantity($attribute->getWpShowQuantity())
->setSortBy($attribute->getWpSortBy())
->setInstantSearch($attribute->getWpInstantSearch())
->setInstantSearchMobile($attribute->getWpInstantSearchMobile())
->setCategoryVisibility($attribute->getWpCategoryVisibility())
->setCategoryIds($categoryIds)
->save();
}
}
return $this;
}
}
@@ -0,0 +1,195 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\CatalogSearch;
use Magento\Catalog\Model\Layer\Resolver;
use Magento\CatalogSearch\Helper\Data as CatalogSearchHelper;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\View\Result\PageFactory;
use Magento\Search\Model\QueryFactory;
use Magento\Store\Model\StoreManagerInterface;
use WeltPixel\LayeredNavigation\Helper\Data as WpHelper;
/**
* Class View
* @package WeltPixel\LayeredNavigation\Plugin\Category
*/
class ResultView
{
/**
* Catalog session
*
* @var Session
*/
protected $_catalogSession;
/**
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var QueryFactory
*/
private $_queryFactory;
/**
* Catalog Layer Resolver
*
* @var Resolver
*/
protected $layerResolver;
/**
* @var JsonFactory
*/
protected $_resultJsonFactory;
/**
* @var PageFactory
*/
protected $_resultPageFactory;
/**
* @var CatalogSearchHelper
*/
protected $_catalogSearchHelper;
/**
* @var WpHelper
*/
protected $_wpHelper;
/**
* ResultView constructor.
* @param StoreManagerInterface $storeManager
* @param QueryFactory $queryFactory
* @param Resolver $layerResolver
* @param JsonFactory $resultJsonFactory
* @param PageFactory $resultPageFactory
* @param CatalogSearchHelper $catalogSearchHelper
* @param WpHelper $wpHelper
*/
public function __construct(
StoreManagerInterface $storeManager,
QueryFactory $queryFactory,
Resolver $layerResolver,
JsonFactory $resultJsonFactory,
PageFactory $resultPageFactory,
CatalogSearchHelper $catalogSearchHelper,
WpHelper $wpHelper
) {
$this->_storeManager = $storeManager;
$this->_queryFactory = $queryFactory;
$this->layerResolver = $layerResolver;
$this->_resultJsonFactory = $resultJsonFactory;
$this->_resultPageFactory = $resultPageFactory;
$this->_catalogSearchHelper = $catalogSearchHelper;
$this->_wpHelper = $wpHelper;
}
/**
* @param \Magento\CatalogSearch\Controller\Result\Index $subject
* @param \Closure $method
* @return $this|array|mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function aroundExecute(
\Magento\CatalogSearch\Controller\Result\Index $subject,
\Closure $method
) {
if ($subject->getRequest()->getParam('ajax') == 1 && $this->_wpHelper->isEnabled()) {
$this->_wpHelper->updateSliderBodyClass();
$requestUri = $subject->getRequest()->getRequestUri();
$requestUri = preg_replace('/(\?|&)ajax=1/', '', $requestUri);
$subject->getRequest()->setRequestUri($requestUri);
try {
$this->layerResolver->create(Resolver::CATALOG_LAYER_SEARCH);
} catch (\Exception $ex) {
}
/* @var $query \Magento\Search\Model\Query */
$query = $this->_queryFactory->get();
$query->setStoreId($this->_storeManager->getStore()->getId());
$resultJson = $this->_resultJsonFactory->create();
if ($query->getQueryText() != '') {
if ($this->_catalogSearchHelper->isMinQueryLength()) {
$query->setId(0)->setIsActive(1)->setIsProcessed(1);
} else {
$query->saveIncrementalPopularity();
if ($query->getRedirect()) {
$data = [
'success' => true,
'redirect_url' => $query->getRedirect()
];
return $resultJson->setData($data);
}
}
$this->_catalogSearchHelper->checkNotes();
$pageFactory = $this->_resultPageFactory->create();
$resultsBlockHtml = $pageFactory->getLayout()->getBlock('search.result')->toHtml();
$leftNavBlockHtml = $pageFactory->getLayout()->getBlock('catalogsearch.leftnav')->toHtml();
$dataLayerContent = '';
$dataLayerContentGa4 = '';
$dataLayerBlock = $pageFactory->getLayout()->getBlock('head.additional');
if ($dataLayerBlock) {
$dLBlockHtml = $dataLayerBlock->toHtml();
preg_match('/var dlObjects ?= ?(.*?)];/', $dLBlockHtml, $matches);
if (count($matches) == 2) {
$dataLayerContent = $matches[1] . ']';
}
preg_match('/var dl4Objects ?= ?(.*?)];/', $dLBlockHtml, $matchesGa4);
if (count($matchesGa4) == 2) {
$dataLayerContentGa4 = $matchesGa4[1] . ']';
}
}
$ga4ServerSideViewItemListContent = '';
$ga4ServerSideViewItemListBlock = $pageFactory->getLayout()->getBlock('weltpixel-ga4-server-view-item-list');
if ($ga4ServerSideViewItemListBlock) {
$ga4ServerSideViewItemListBlockHtml = $ga4ServerSideViewItemListBlock->toHtml();
preg_match('/<input.*id="wp_ga4_server_side_view_item_list".*value="(.*?)"/', $ga4ServerSideViewItemListBlockHtml, $matchesGa4ServerSide);
if (count($matchesGa4ServerSide) == 2) {
$ga4ServerSideViewItemListContent = $matchesGa4ServerSide[1];
}
}
return $this->_resultJsonFactory->create()->setData(
[
'success' => true,
'html' => [
'products_list' => $resultsBlockHtml,
'filters' => $leftNavBlockHtml,
'dataLayer' => $dataLayerContent,
'dataLayerGA4' => $dataLayerContentGa4,
'ga4ServerSideItemListHash' => $ga4ServerSideViewItemListContent
]
]
);
} else {
$data = [
'success' => true,
'redirect_url' => $this->_redirect->getRedirectUrl()
];
return $resultJson->setData($data);
}
} else {
return $method();
}
}
}
@@ -0,0 +1,103 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\Category;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\View\Result\Page;
use Magento\Framework\UrlInterface;
use WeltPixel\LayeredNavigation\Helper\Data;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Action;
use WeltPixel\NavigationLinks\Model\Attribute\Source\CategoryLayout;
/**
* Class Design
* @package WeltPixel\LayeredNavigation\Plugin\Category
*/
class Design
{
/**
* @var JsonFactory
*/
protected $_resultJsonFactory;
/**
* @var UrlInterface
*/
protected $_storeManager;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var PageFactory
*/
protected $pageFactory;
/**
* View constructor.
* @param JsonFactory $resultJsonFactory
* @param UrlInterface $_storeManager
* @param Data $wpHelper
* @param PageFactory $pageFactory
*/
public function __construct(
JsonFactory $resultJsonFactory,
UrlInterface $_storeManager,
Data $wpHelper,
PageFactory $pageFactory
)
{
$this->_resultJsonFactory = $resultJsonFactory;
$this->_storeManager = $_storeManager;
$this->_wpHelper = $wpHelper;
$this->pageFactory = $pageFactory;
}
/**
* @param \Magento\Catalog\Model\Design $subject
* @param \Magento\Framework\DataObject $result
* @param Category|Product $object
* @return \Magento\Framework\DataObject
*/
public function afterGetDesignSettings(\Magento\Catalog\Model\Design $subject, $result, $object)
{
if(!$this->_wpHelper->isEnabled()) {
return $result;
}
if ($object instanceof Product) {
$currentCategory = $object->getCategory();
} else {
$currentCategory = $object;
}
if (!$currentCategory) {
return $result;
}
$sideBarStyle = $this->_wpHelper->getSidebarStyle();
if ($sideBarStyle != 3) {
return $result;
}
$result->setPageLayout('1column');
$pageLayoutHandles = $result->getPageLayoutHandles();
$horizontalLayoutHandle = ['wpln' => 'horizontalnavigation'];
if (is_array($pageLayoutHandles)) {
$pageLayoutHandles['wpln'] = 'horizontalnavigation';
} else {
$pageLayoutHandles = $horizontalLayoutHandle;
}
$result->setPageLayoutHandles($pageLayoutHandles);
return $result;
}
}
@@ -0,0 +1,144 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\Category;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\View\Result\Page;
use Magento\Framework\UrlInterface;
use WeltPixel\LayeredNavigation\Helper\Data;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Action;
/**
* Class View
* @package WeltPixel\LayeredNavigation\Plugin\Category
*/
class View
{
/**
* @var JsonFactory
*/
protected $_resultJsonFactory;
/**
* @var UrlInterface
*/
protected $_storeManager;
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var PageFactory
*/
protected $pageFactory;
/**
* View constructor.
* @param JsonFactory $resultJsonFactory
* @param UrlInterface $_storeManager
* @param Data $wpHelper
* @param PageFactory $pageFactory
*/
public function __construct(
JsonFactory $resultJsonFactory,
UrlInterface $_storeManager,
Data $wpHelper,
PageFactory $pageFactory
)
{
$this->_resultJsonFactory = $resultJsonFactory;
$this->_storeManager = $_storeManager;
$this->_wpHelper = $wpHelper;
$this->pageFactory = $pageFactory;
}
/**
* @param Action $subject
* @param $page
* @return $this|void
*/
public function afterExecute(Action $subject, $page)
{
if ($this->_wpHelper->isEnabled()) {
$this->_wpHelper->updateSliderBodyClass();
}
if(!$this->_wpHelper->isAjaxEnabled() || !$this->_wpHelper->isEnabled()) {
return $page;
}
$response = $page;
if ($response instanceof Page) {
if ($subject->getRequest()->getParam('ajax') == 1) {
$subject->getRequest()->getQuery()->set('ajax', null);
$requestUri = $subject->getRequest()->getRequestUri();
$requestUri = preg_replace('/(\?|&)ajax=1/', '', $requestUri);
$subject->getRequest()->setRequestUri($requestUri);
$productsList = $response->getLayout()->getBlock('category.products.list');
$listMode = $subject->getRequest()->getParam('product_list_mode');
if($listMode) {
$productsList->getChildBlock('product_list_toolbar')->setData('_current_grid_mode', $listMode);
}
$productsListBlockHtml = $productsList->toHtml();
$leftNavBlockHtml = $response->getLayout()->getBlock('catalog.leftnav')->toHtml();
$dataLayerContent = '';
$dataLayerContentGa4 = '';
$dataLayerBlock = $response->getLayout()->getBlock('head.additional');
if ($dataLayerBlock) {
$dLBlockHtml = $dataLayerBlock->toHtml();
preg_match('/var dlObjects ?= ?(.*?)];/', $dLBlockHtml, $matches);
if (count($matches) == 2) {
$dataLayerContent = $matches[1] . ']';
}
preg_match('/var dl4Objects ?= ?(.*?)];/', $dLBlockHtml, $matchesGa4);
if (count($matchesGa4) == 2) {
$dataLayerContentGa4 = $matchesGa4[1] . ']';
}
}
$ga4ServerSideViewItemListContent = '';
$ga4ServerSideViewItemListBlock = $response->getLayout()->getBlock('weltpixel-ga4-server-view-item-list');
if ($ga4ServerSideViewItemListBlock) {
$ga4ServerSideViewItemListBlockHtml = $ga4ServerSideViewItemListBlock->toHtml();
preg_match('/<input.*id="wp_ga4_server_side_view_item_list".*value="(.*?)"/', $ga4ServerSideViewItemListBlockHtml, $matchesGa4ServerSide);
if (count($matchesGa4ServerSide) == 2) {
$ga4ServerSideViewItemListContent = $matchesGa4ServerSide[1];
}
}
$tags = [];
$blocksList = [$productsList,$leftNavBlockHtml];
foreach ($blocksList as $block) {
if ($block instanceof \Magento\Framework\DataObject\IdentityInterface) {
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
return $this->_resultJsonFactory->create()->setData(
[
'success' => true,
'html' => [
'products_list' => $productsListBlockHtml,
'filters' => $leftNavBlockHtml,
'dataLayer' => $dataLayerContent,
'dataLayerGA4' => $dataLayerContentGa4,
'ga4ServerSideItemListHash' => $ga4ServerSideViewItemListContent
]
]
)->setHeader('X-Magento-Tags', implode(',', $tags));
}
}
return $response;
}
}
@@ -0,0 +1,145 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\Layer;
use WeltPixel\LayeredNavigation\Helper\Data;
/**
* Class FilterList
* @package WeltPixel\LayeredNavigation\Plugin\Layer
*/
class FilterList
{
const RATING_FILTER_CLASS = 'WeltPixel\LayeredNavigation\Model\Layer\Filter\Rating';
/**
* @var \WeltPixel\LayeredNavigation\Helper\Data
*/
protected $_wpHelper;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var \Magento\Catalog\Model\Layer
*/
protected $_layer;
/**
* FilterList constructor.
* @param Data $wpHelper
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(
Data $wpHelper,
\Magento\Framework\ObjectManagerInterface $objectManager
)
{
$this->_wpHelper = $wpHelper;
$this->_objectManager = $objectManager;
}
/**
* Remove category filter if disabled in configuration
*
* @param \Magento\Catalog\Model\Layer\FilterList $subject
* @param $result
* @return array
*/
public function afterGetFilters(\Magento\Catalog\Model\Layer\FilterList $subject, $result)
{
if(!$this->_wpHelper->isEnabled()){
return $result;
}
$filteredResult = [];
if(!$this->_wpHelper->showCategoriesBlock()) {
foreach($result as $r) {
if($r->getRequestVar() != $this->_wpHelper->getCategoryParamLabel()) {
$filteredResult[] = $r;
}
}
return $filteredResult;
} else {
return $result;
}
}
/**
* @param \Magento\Catalog\Model\Layer\FilterList $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\Layer $layer
* @return array|mixed
*/
public function aroundGetFilters( \Magento\Catalog\Model\Layer\FilterList $subject, \Closure $proceed, \Magento\Catalog\Model\Layer $layer)
{
if(!$this->_wpHelper->isEnabled()){
$result = $proceed($layer);
return $result;
}
$result = $proceed($layer);
if($this->_wpHelper->getRatingFilterName()) {
$result[] = $this->getRatingFilter($layer);
$result = $this->_injectRatingFilter($result);
}
return $result;
}
/**
* @param $filters
* @return mixed
*/
protected function _injectRatingFilter($filters) {
$ratingFilterPosition = $this->_wpHelper->getRatingFilterPosition();
if(count($filters) > $ratingFilterPosition) {
foreach($filters as $k => $filter) {
$class = self::RATING_FILTER_CLASS;
if($filter instanceof $class){
$ratingFilterKey = $k;
break;
}
}
$ratingFilterArr = array_splice($filters, $ratingFilterKey, 1);
array_splice($filters, $ratingFilterPosition, 0, $ratingFilterArr);
}
return $filters;
}
/**
* @param $layer
* @return mixed
*/
public function getRatingFilter($layer)
{
$filter = $this->_objectManager->create(
$this->getRatingFilterClass(),
['layer' => $layer]
);
return $filter;
}
/**
* @return string
*/
public function getRatingFilterClass() {
return self::RATING_FILTER_CLASS;
}
}
@@ -0,0 +1,130 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\Model\Layer\Filter;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
use WeltPixel\LayeredNavigation\Model\Layer\Filter as FilterModel;
/**
* Class Item
* @package WeltPixel\LayeredNavigation\Model\Plugin\Layer\Filter
*/
class Item
{
/** @var \Magento\Framework\UrlInterface */
protected $_url;
/** @var \Magento\Theme\Block\Html\Pager */
protected $_htmlPagerBlock;
/** @var \Magento\Framework\App\RequestInterface */
protected $_request;
/** @var \WeltPixel\LayeredNavigation\Helper\Data */
protected $_wpHelper;
/**
* @var FilterModel
*/
protected $_filterModel;
/**
* Item constructor.
* @param \Magento\Framework\UrlInterface $url
* @param \Magento\Theme\Block\Html\Pager $htmlPagerBlock
* @param \Magento\Framework\App\RequestInterface $request
* @param LayerHelper $_wpHelper
* @param FilterModel $filterModel
*/
public function __construct(
\Magento\Framework\UrlInterface $url,
\Magento\Theme\Block\Html\Pager $htmlPagerBlock,
\Magento\Framework\App\RequestInterface $request,
LayerHelper $wpHelper,
FilterModel $filterModel
)
{
$this->_url = $url;
$this->_htmlPagerBlock = $htmlPagerBlock;
$this->_request = $request;
$this->_wpHelper = $wpHelper;
$this->_filterModel = $filterModel;
}
/**
* @param \Magento\Catalog\Model\Layer\Filter\Item $item
* @param $proceed
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function aroundGetRemoveUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed)
{
if (!$this->_wpHelper->isEnabled()) {
return $proceed();
}
$value = [];
$filter = $item->getFilter();
$value = $this->_filterModel->getFilterValue($filter);
$itemValue = $item->getValue();
if (is_array($item->getValue())) {
$itemValue = implode('-', $item->getValue());
}
if (in_array($itemValue, $value)) {
$value = array_diff($value, [$itemValue]);
}
$params['_query'] = [$filter->getRequestVar() => count($value) ? implode(',', $value) : $filter->getResetValue()];
$params['_current'] = true;
$params['_use_rewrite'] = true;
$params['_escape'] = true;
return $this->_url->getUrl('*/*/*', $params);
}
/**
* @param \Magento\Catalog\Model\Layer\Filter\Item $item
* @param $proceed
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function aroundGetUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed)
{
if (!$this->_wpHelper->isEnabled() || $this->_wpHelper->isAjaxEnabled()) {
return $proceed();
}
$filter = $item->getFilter();
if ($filter instanceof \WeltPixel\LayeredNavigation\Model\Layer\Filter\Rating
|| $filter instanceof \WeltPixel\LayeredNavigation\Model\Layer\Filter\Category) {
$isMultiSelect = false;
} else {
$isMultiSelect = $this->_filterModel->isMultiselect($filter->getAttributeModel()->getAttributeId());
}
if (!$isMultiSelect) {
return $proceed();
}
$requestVarValue = $this->_filterModel->getFilterValue($filter);
if (in_array($item->getValue(), $requestVarValue)) {
$requestVarValue = array_diff($requestVarValue, [$item->getValue()]);
} else {
array_push($requestVarValue, $item->getValue());
}
$requestVarValue = implode(",", $requestVarValue);
$query = [
$filter->getRequestVar() => $requestVarValue,
$this->_htmlPagerBlock->getPageVarName() => null,
];
return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);
}
}
@@ -0,0 +1,111 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Plugin\Swatches;
use WeltPixel\LayeredNavigation\Helper\Data as LayerHelper;
use WeltPixel\LayeredNavigation\Model\Layer\Filter as FilterModel;
/**
* Class RenderLayered
* @package WeltPixel\LayeredNavigation\Plugin\Swatches
*/
class RenderLayered
{
/** @var \Magento\Framework\UrlInterface */
protected $_url;
/** @var \Magento\Theme\Block\Html\Pager */
protected $_htmlPagerBlock;
/** @var \Magento\Framework\App\RequestInterface */
protected $_request;
/** @var \WeltPixel\LayeredNavigation\Helper\Data */
protected $_wpHelper;
/**
* @var FilterModel
*/
protected $_filterModel;
/**
* @var \Magento\Eav\Model\ResourceModel\Entity\Attribute
*/
protected $eavAttribute;
/**
* Item constructor.
* @param \Magento\Framework\UrlInterface $url
* @param \Magento\Theme\Block\Html\Pager $htmlPagerBlock
* @param \Magento\Framework\App\RequestInterface $request
* @param LayerHelper $_wpHelper
* @param FilterModel $filterModel
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute $eavAttribute
*/
public function __construct(
\Magento\Framework\UrlInterface $url,
\Magento\Theme\Block\Html\Pager $htmlPagerBlock,
\Magento\Framework\App\RequestInterface $request,
LayerHelper $wpHelper,
FilterModel $filterModel,
\Magento\Eav\Model\ResourceModel\Entity\Attribute $eavAttribute
) {
$this->_url = $url;
$this->_htmlPagerBlock = $htmlPagerBlock;
$this->_request = $request;
$this->_wpHelper = $wpHelper;
$this->_filterModel = $filterModel;
$this->eavAttribute = $eavAttribute;
}
/**
* @param \Magento\Swatches\Block\LayeredNavigation\RenderLayered $renderLayered
* @param $proceed
* @param string $attributeCode
* @param int $optionId
* @return string
*/
public function aroundBuildUrl(
\Magento\Swatches\Block\LayeredNavigation\RenderLayered $renderLayered,
$proceed,
$attributeCode,
$optionId
) {
if (!$this->_wpHelper->isEnabled() || $this->_wpHelper->isAjaxEnabled()) {
return $proceed($attributeCode, $optionId);
}
$attributeId = $this->eavAttribute->getIdByCode('catalog_product', $attributeCode);
$isMultiSelect = $this->_filterModel->isMultiselect($attributeId);
if (!$isMultiSelect) {
return $proceed($attributeCode, $optionId);
}
$filterValue = $this->_request->getParam($attributeCode);
$requestVarValue = [];
if (!empty($filterValue)) {
$requestVarValue = explode(',', $filterValue);
}
if (in_array($optionId, $requestVarValue)) {
$requestVarValue = array_diff($requestVarValue, [$optionId]);
} else {
array_push($requestVarValue, $optionId);
}
$requestVarValue = implode(",", $requestVarValue);
$query = [
$attributeCode => $requestVarValue,
$this->_htmlPagerBlock->getPageVarName() => null
];
return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);
}
}
+35
View File
@@ -0,0 +1,35 @@
# magento2-weltpixel-layered-navigation
### Installation
Dependencies:
- magento2-weltpixel-backend (see https://github.com/Weltpixel/magento2-weltpixel-backend)
With composer:
```sh
$ composer config repositories.weltpixel-magento2-weltpixel-backend git https://github.com/Weltpixel/magento2-weltpixel-backend.git
$ composer require weltpixel/magento2-weltpixel-backend:dev-master
$ composer config repositories.weltpixel-magento2-weltpixel-layered-navigation git https://github.com/Weltpixel/magento2-weltpixel-layered-navigation.git
$ composer require weltpixel/magento2-weltpixel-layered-navigation:dev-master
```
Manually:
Important: Ensure you also install the shared Backend module. If it's already installed, you can skip this. Details in the repo at https://github.com/Weltpixel/magento2-weltpixel-backend.
Copy the zip into app/code/WeltPixel/LayeredNavigation directory
#### After installation by either means, enable the extension by running following commands:
```sh
$ php bin/magento module:enable WeltPixel_LayeredNavigation --clear-static-content
$ php bin/magento setup:upgrade
```
### Documentation
For detailed documentation, please visit: https://github.com/Weltpixel/magento2-weltpixel-documentation/tree/master/Magento2/LayeredNavigation
@@ -0,0 +1,125 @@
<?php
namespace WeltPixel\LayeredNavigation\Setup\Patch\Schema;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class AddAttributeOptionsTable implements SchemaPatchInterface, PatchVersionInterface
{
/**
* @var SchemaSetupInterface $schemaSetup
*/
private $schemaSetup;
/**
* @param SchemaSetupInterface $schemaSetup
*/
public function __construct(SchemaSetupInterface $schemaSetup)
{
$this->schemaSetup = $schemaSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$setup = $this->schemaSetup;
$this->schemaSetup->startSetup();
/**
* Create table 'weltpixel_ln_attribute_options'
*/
$table = $setup->getConnection()->newTable(
$setup->getTable('weltpixel_ln_attribute_options')
)->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Id'
)->addColumn(
'attribute_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Attribute Id'
)->addColumn(
'display_option',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Filter Display Option'
)->addColumn(
'visible_options',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '99'],
'Initial number of options'
)->addColumn(
'visible_options_step',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '99'],
'Expandable items behaviour'
)->addColumn(
'is_multiselect',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Enable Multiselect'
)->addColumn(
'show_quantity',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Show Quantity'
)->addColumn(
'sort_by',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '1'],
'Sort By'
)->addIndex(
$setup->getIdxName($setup->getTable('weltpixel_ln_attribute_options'),['id']),
['id']
)->addForeignKey(
$setup->getFkName('weltpixel_ln_attribute_options', 'attribute_id', 'eav_attribute', 'attribute_id'),
'attribute_id',
$setup->getTable('eav_attribute'),
'attribute_id',
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'WeltPixel Layered Navigation Attribute Options'
);
$setup->getConnection()->createTable($table);
$this->schemaSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.0.0';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
}
@@ -0,0 +1,108 @@
<?php
namespace WeltPixel\LayeredNavigation\Setup\Patch\Schema;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class ModifyAttributeOptionsTableColumns implements SchemaPatchInterface, PatchVersionInterface
{
/**
* @var SchemaSetupInterface $schemaSetup
*/
private $schemaSetup;
/**
* @param SchemaSetupInterface $schemaSetup
*/
public function __construct(SchemaSetupInterface $schemaSetup)
{
$this->schemaSetup = $schemaSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$setup = $this->schemaSetup;
$setup->startSetup();
$connection = $setup->getConnection();
$tableName = $setup->getTable('weltpixel_ln_attribute_options');
if ($setup->getConnection()->isTableExists($tableName)) {
$columns = [
'instant_search' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
'default' => 0,
'unsigned' => true,
'nullable' => false,
'comment' => 'Instant Search Desktop',
],
'instant_search_mobile' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
'default' => 0,
'unsigned' => true,
'nullable' => false,
'comment' => 'Instant Search Mobile',
],
'category_visibility' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
'default' => 0,
'unsigned' => true,
'nullable' => false,
'comment' => 'Category Visibility',
],
'category_ids' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'unsigned' => true,
'nullable' => true,
'comment' => 'Categories ids list',
],
'keep_open_after_filter' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
'default' => 0,
'unsigned' => true,
'nullable' => false,
'comment' => 'Keep attribute opened after filtering',
'after' => 'is_multiselect'
]
];
foreach ($columns as $name => $definition) {
if (!$connection->tableColumnExists($tableName, $name)) {
$connection->addColumn($tableName, $name, $definition);
}
}
}
$setup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.0.4';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [
AddAttributeOptionsTable::class
];
}
}

Some files were not shown because too many files have changed in this diff Show More