This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -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,26 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml;
/**
* Class Licenses
* @package WeltPixel\Backend\Block\Adminhtml
*/
class Licenses extends \Magento\Backend\Block\Template
{
/**
* @return string
*/
public function getLicensePostUrl()
{
return $this->getUrl('weltpixel_backend/licenses/post');
}
/**
* @return string
*/
public function getLicensesUrl()
{
return $this->getUrl('weltpixel_backend/licenses/index');
}
}
@@ -0,0 +1,160 @@
<?php
namespace WeltPixel\Backend\Block\Adminhtml;
/**
* Class ModulesVersion
* @package WeltPixel\Backend\Block\Adminhtml
*/
class ModulesVersion extends \Magento\Backend\Block\Template
{
const MODULE_VERSIONS = 'https://www.weltpixel.com/weltpixel_extensions.json';
/**
* @var \Magento\Framework\App\DeploymentConfig
*/
protected $deploymentConfig;
/**
* @var \Magento\Framework\Component\ComponentRegistrarInterface
*/
protected $componentRegistrar;
/**
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
*/
protected $readFactory;
/**
* @var array
*/
protected $latestVersions;
/**
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
* @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Magento\Framework\App\DeploymentConfig $deploymentConfig,
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar,
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
$this->deploymentConfig = $deploymentConfig;
$this->readFactory = $readFactory;
$this->componentRegistrar = $componentRegistrar;
parent::__construct($context, $data);
}
/**
* @return array
*/
protected function getModulesLatestVersions()
{
$curl = curl_init(self::MODULE_VERSIONS);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
$response = curl_exec($curl);
$latestVersions = json_decode($response, true);
return $latestVersions;
}
/**
* @return array
*/
public function getModuleVersions()
{
$this->latestVersions = $this->getModulesLatestVersions();
$modules = $this->deploymentConfig->get('modules');
$moduleDetails = [];
foreach ($modules as $moduleName => $isEnabled) {
if (strpos($moduleName, 'WeltPixel_') !== false || strpos($moduleName, 'WeSupply_') !== false) {
$moduleDetails[$moduleName]['enabled'] = $isEnabled;
$moduleDetails[$moduleName]['version'] = $this->getComposerVersion($moduleName, \Magento\Framework\Component\ComponentRegistrar::MODULE);
if (isset($this->latestVersions['modules'][$moduleName]['version'])) {
$moduleDetails[$moduleName]['latest_version'] = $this->latestVersions['modules'][$moduleName]['version'];
$moduleDetails[$moduleName]['theme_module'] = $this->latestVersions['modules'][$moduleName]['theme_module'];
} else {
$moduleDetails[$moduleName]['latest_version'] = __('N/A');
$moduleDetails[$moduleName]['theme_module'] = false;
}
/** Adding latest version comparison messages */
if (version_compare($moduleDetails[$moduleName]['latest_version'], $moduleDetails[$moduleName]['version']) < 1) {
$moduleDetails[$moduleName]['status_message'] = __('Up to Date');
$moduleDetails[$moduleName]['status'] = true;
} else {
$moduleDetails[$moduleName]['status_message'] = __('Update needed');
$moduleDetails[$moduleName]['status'] = false;
}
}
}
return $moduleDetails;
}
/**
* @return array
*/
public function getThemeVersions()
{
$themeDetails = [];
$themes = [
'Pearl' => 'frontend/Pearl/weltpixel',
'Pearl custom' => 'frontend/Pearl/weltpixel_custom'
];
foreach ($themes as $name => $theme) {
$themeVersion = $this->getComposerVersion($theme, \Magento\Framework\Component\ComponentRegistrar::THEME);
if ($themeVersion != 'N/A') {
$themeDetails[$name]['version'] = $themeVersion;
if (isset($this->latestVersions['themes'][$name])) {
$themeDetails[$name]['latest_version'] = $this->latestVersions['themes'][$name];
} else {
$themeDetails[$name]['latest_version'] = __('N/A');
}
/** Adding latest version comparison messages */
if (version_compare($themeDetails[$name]['latest_version'], $themeDetails[$name]['version']) < 1) {
$themeDetails[$name]['status_message'] = __('Up to Date');
$themeDetails[$name]['status'] = true;
} else {
$themeDetails[$name]['status_message'] = __('Update needed');
$themeDetails[$name]['status'] = false;
}
}
}
return $themeDetails;
}
/**
* @param $moduleName
* @return string
*/
protected function getComposerVersion($moduleName, $type)
{
$path = $this->componentRegistrar->getPath(
$type,
$moduleName
);
if (!$path) {
return __('N/A');
}
$dirReader = $this->readFactory->create($path);
$composerJsonData = $dirReader->readFile('composer.json');
$data = json_decode($composerJsonData, true);
return $data['version'];
}
}
@@ -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 Modules extends \WeltPixel\Backend\Controller\Adminhtml\Debugger
{
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger_Modules';
/**
* @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(__('Modules'));
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');
}
}
@@ -0,0 +1,56 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml;
abstract class Licenses extends \Magento\Backend\App\Action
{
/**
* Authorization level of a basic admin session
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Licenses';
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @var \Magento\Framework\Controller\Result\JsonFactory
*/
protected $resultJsonFactory;
/**
* @var \WeltPixel\Backend\Helper\License
*/
protected $wpHelper;
/**
* @var \WeltPixel\Backend\Model\LicenseFactory
*/
protected $licenseFactory;
/**
* Constructor
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \WeltPixel\Backend\Helper\License $wpHelper
* @param \WeltPixel\Backend\Model\LicenseFactory $licenseFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\WeltPixel\Backend\Helper\License $wpHelper,
\WeltPixel\Backend\Model\LicenseFactory $licenseFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
$this->wpHelper = $wpHelper;
$this->licenseFactory = $licenseFactory;
}
}
@@ -0,0 +1,16 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml\Licenses;
class Index extends \WeltPixel\Backend\Controller\Adminhtml\Licenses
{
const ADMIN_RESOURCE = 'WeltPixel_Backend::Modules_License';
/**
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
$this->wpHelper->checkAndUpdate();
return $resultPage = $this->resultPageFactory->create();
}
}
@@ -0,0 +1,59 @@
<?php
namespace WeltPixel\Backend\Controller\Adminhtml\Licenses;
class Post extends \WeltPixel\Backend\Controller\Adminhtml\Licenses
{
const ADMIN_RESOURCE = 'WeltPixel_Backend::Modules_License';
/**
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
$result = [];
$lcK = trim($this->getRequest()->getParam('license'));
$moduleName = $this->getRequest()->getParam('module_name');
try {
$license = $this->licenseFactory->create();
$license->load($moduleName, 'module_name');
$license->setModuleName($moduleName);
$license->setLicenseKey($lcK);
$license->save();
$license->updMdsInf();
$result['error'] = false;
$result['license'] = $lcK;
$result['module_name'] = $moduleName;
$licenseValidity = $license->isLcVd($lcK, $moduleName);
$result['is_valid'] = ($licenseValidity) ? 'license-status-ok' : 'license-status-nok';
$result['is_valid_msg'] = ($licenseValidity) ? __('Valid') : __('Invalid');
$result['message'] = __('The license key was successfully updated.');
$result['message'] .= "<br/><br/>";
if ($licenseValidity) {
$result['message'] .= '<div class="license-pmsg valid-license-pmsg">' . __('The license key introduced is valid') . '</div>';
} else {
$userFriendlyNames = $license->getUserFriendlyModuleNames();
$options = [];
$options['module_name'] = $moduleName;
$options['license'] = $lcK;
$licenseErrorMessage = $this->wpHelper->getLicenseErrorMessage($options, $userFriendlyNames, false);
$result['message'] .= '<div class="license-pmsg invalid-license-pmsg">' . __('The license key you entered is invalid.')
. '<br/>' . $licenseErrorMessage . '</div><br/>'
. '<b>' . __('Common reasons:') . '</b><br>'
. __('- Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc..') . '<br/><br/>'
. __('- Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation.') . '<br/><br/>'
. __('- Wrong module - using a license key from a different product or product pack.');
}
} catch (\Exception $ex) {
$result['error'] = true;
$result['message'] = __('There was a problem with the license key saving.') . ' ' . $ex->getMessage();
}
$resultJson = $this->resultJsonFactory->create();
$resultJson->setData($result);
return $resultJson;
}
}
@@ -0,0 +1,27 @@
<?php
namespace WeltPixel\Backend\Cron;
class ModuleInfoUpdate
{
/**
* @var \WeltPixel\Backend\Model\License
*/
protected $license;
public function __construct(
\WeltPixel\Backend\Model\License $license
) {
$this->license = $license;
}
/**
* @return \WeltPixel\Backend\Cron\ModuleInfoUpdate
*/
public function execute()
{
$this->license->updMdsInf();
return $this;
}
}
@@ -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.
@@ -0,0 +1,105 @@
<?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;
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ProductMetadataInterface $productMetadata
* @param ScheduleFactory $scheduleFactory
* @param \Magento\Framework\Stdlib\DateTime\DateTime $datetime
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ProductMetadataInterface $productMetadata,
ScheduleFactory $scheduleFactory,
\Magento\Framework\Stdlib\DateTime\DateTime $datetime
)
{
parent::__construct($context);
$this->productMetaData = $productMetadata;
$this->scheduleFactory = $scheduleFactory;
$this->dateTime = $datetime;
}
/**
* @return string
*/
public function getCurrentServerUser()
{
return get_current_user();
}
/**
* @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();
}
}
@@ -0,0 +1,175 @@
<?php
namespace WeltPixel\Backend\Helper;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class License extends \Magento\Framework\App\Helper\AbstractHelper
{
/** @var \WeltPixel\Backend\Model\License */
protected $license;
/**
* @var \WeltPixel\Backend\Model\LicenseFactory
*/
protected $licenseFactory;
/**
* @var \Magento\Backend\Model\UrlInterface
*/
protected $backendUrl;
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \WeltPixel\Backend\Model\License $license
* @param \WeltPixel\Backend\Model\LicenseFactory $licenseFactory ,
* @param \Magento\Backend\Model\UrlInterface $backendUrl
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\WeltPixel\Backend\Model\License $license,
\WeltPixel\Backend\Model\LicenseFactory $licenseFactory,
\Magento\Backend\Model\UrlInterface $backendUrl
)
{
parent::__construct($context);
$this->license = $license;
$this->licenseFactory = $licenseFactory;
$this->backendUrl = $backendUrl;
}
/**
* @return array
*/
public function getMdsL()
{
return $this->license->getMdsL();
}
/**
* @return array
*/
public function getModulesListForDisplay()
{
$modulesList = $this->getMdsL();
foreach ($modulesList as $key => $options) {
if (version_compare($options['version'], \WeltPixel\Backend\Model\License::LICENSE_VERSION) < 0) {
unset($modulesList[$key]);
}
}
return $modulesList;
}
/**
* @param $license
* @param $module
* @return bool
*/
public function isLcVd($license, $module)
{
return $this->license->isLcVd($license, $module);
}
/**
* @param array $licenseOptions
* @param array $userFriendlyNames
* @param bool $usePrefix
* @return string
*/
public function getLicenseErrorMessage($licenseOptions, $userFriendlyNames, $usePrefix = true)
{
$moduleName = isset($userFriendlyNames[$licenseOptions['module_name']]) ? $userFriendlyNames[$licenseOptions['module_name']] : $licenseOptions['module_name'];
$msgPrefix = '';
if ($usePrefix) {
$msgPrefix = '<b>' . $moduleName . '</b>' . ' => ';
}
$defaultMsg = 'This license key is invalid, please add a valid license key. If you believe this is a mistake contact us at <a href="mailto:support@weltpixel.com">support@weltpixel.com</a>';
$license = $licenseOptions['license'];
$licenseDetails = $this->license->getLicenseDetails($license);
if (count($licenseDetails) != 5) return $msgPrefix . $defaultMsg;
$licenseModuleName = isset($userFriendlyNames[$licenseDetails[1]]) ? $userFriendlyNames[$licenseDetails[1]] : $licenseDetails[1];
if ($licenseDetails['1'] != $licenseOptions['module_name']) {
return $msgPrefix . 'Current license is for ' . $licenseModuleName . ' and is being used on a ' . $moduleName . ' installation.';
}
$magentoVersion = $this->license->getMagentoVersion();
$magentoParsedVersion = $magentoVersion;
if ($magentoVersion != "\x63\x6f\x6d\x6d\x75\x6e\x69\x74\x79") {
$magentoParsedVersion = "\x65\x6e\x74\x65\x72\x70\x72\x69\x73\x65";
}
if (($magentoParsedVersion != $licenseDetails[3]) && ($magentoVersion != "community")) {
return $msgPrefix . 'Current license is for ' . $licenseDetails[3] . ' and it not valid when used on ' . $magentoVersion;
}
$domain = $this->license->getMagentoDomain();
$isDomainValid = $this->license->checkDomainValidity($domain, $licenseDetails[2]);
if (!$isDomainValid) {
return $msgPrefix . 'Your license domain ' . $licenseDetails[2] . ' does not match current domain ' . $domain;
}
return $msgPrefix . $defaultMsg;
}
/**
* @TODO might need to check and remove if some modules were meanwhile disabled
* @return void
*/
public function checkAndUpdate()
{
$modules = $this->getMdsL();
foreach ($modules as $name => $options) {
$license = $this->licenseFactory->create();
try {
$license->load($name, 'module_name');
$license->setModuleName($name);
$license->setLicenseKey($options['license']);
$license->save();
} catch (\Exception $ex) {
}
}
}
public function updMdsInf()
{
$this->license->updMdsInf();
}
/**
* @return bool|string
*/
public function getLicenseMessage()
{
if ($this->_request->isAjax()) {
return false;
}
$messages = [];
$modules = $this->getModulesListForDisplay();
$userFriendlyNames = $this->license->getUserFriendlyModuleNames();
foreach ($modules as $name => $options) {
if (!$this->isLcVd($options['license'], $options['module_name'])) {
$invalidReasonMsg = $this->getLicenseErrorMessage($options, $userFriendlyNames);
$messages[] = $invalidReasonMsg;
}
}
if (count($messages)) {
$moduleList = implode('<br/>', $messages);
return __('License missing or invalid for the following WeltPixel module(s):') . '<br/>' . $moduleList . '<br/><br/>' .
__('You can enter the license key(s)') . ' ' . '<a href="' . $this->backendUrl->getUrl('weltpixel_backend/licenses/index') . '">'
. __('here.') . '</a><br/>' . __('License key can be found under My Downloadable Products section of your weltpixel.com account.');
}
return false;
}
}
@@ -0,0 +1,105 @@
<?php
namespace WeltPixel\Backend\Helper;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use \Magento\Store\Api\StoreRepositoryInterface;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Utility extends \Magento\Framework\App\Helper\AbstractHelper
{
/** @var ThemeProviderInterface */
protected $themeProvider;
/** @var StoreRepositoryInterface */
protected $storeRepository;
/** @var array */
protected $storeThemesLocales = [];
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param ThemeProviderInterface $themeProvider
* @param StoreRepositoryInterface $storeRepository
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
ThemeProviderInterface $themeProvider,
StoreRepositoryInterface $storeRepository
)
{
parent::__construct($context);
$this->themeProvider = $themeProvider;
$this->storeRepository = $storeRepository;
}
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 = [];
foreach ($stores as $store) {
$storeId = $store["store_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
);
$theme = $this->themeProvider->getThemeById($themeId);
$result[$theme->getThemePath().'/'.$locale] = $storeCode;
}
$this->storeThemesLocales = $result;
return $this->storeThemesLocales;
}
}
@@ -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)')];
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace WeltPixel\Backend\Model;
use Magento\Framework\Config\ConfigOptionsListConstants;
/**
* WeltPixelAdmin Feed model
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Feed extends \Magento\AdminNotification\Model\Feed
{
const XML_FREQUENCY_PATH = 'system/adminnotification/frequency';
/**
* Feed url for WeltPixel Feed
*
* @var string
*/
protected $_weltPixelFeedUrl = 'http://weltpixel.com/notifications.rss';
/**
* Retrieve feed url
*
* @return string
*/
public function getFeedUrl()
{
return $this->_weltPixelFeedUrl;
}
/**
* Retrieve Last update time
*
* @return int
*/
public function getLastUpdate()
{
return $this->_cacheManager->load('weltpixel_notifications_lastcheck');
}
/**
* Set last update time (now)
*
* @return $this
*/
public function setLastUpdate()
{
$this->_cacheManager->save(time(), 'weltpixel_notifications_lastcheck');
return $this;
}
}
@@ -0,0 +1,846 @@
<?php
namespace WeltPixel\Backend\Model;
class License extends \Magento\Framework\Model\AbstractModel
{
const CACHE_TAG = 'weltixel_license';
const LICENSE_CONSTANT = "\x57\x45\x4c\x54\x50\x49\x58\x45\x4c";
const LICENSE_PASSWORD = "\x77\x65\x6c\x74\x70\x69\x78\x65\x6c\x5f\x63\x6f\x73\x6d\x6f";
const LICENSE_IV = "\x77\x65\x6c\x74\x5f\x69\x76";
const LICENSE_CIPHER = "\x61\x65\x73\x2d\x31\x32\x38\x2d\x63\x62\x63";
const LICENCE_KEY_PATH = "\x65\x74\x63" . DIRECTORY_SEPARATOR . "\x6d\x6f\x64\x75\x6c\x65\x2e\x69\x6e\x66\x6f";
const BUNDLE_KEY_PATH = "\x65\x74\x63" . DIRECTORY_SEPARATOR . "\x62\x75\x6e\x64\x6c\x65\x2e\x69\x6e\x66\x6f";
const MODULE_INFO_PREFIX = "\x77\x70\x2f\x69\x6e\x66\x6f\x2f";
const LICENSE_INFO_PREFIX = "\x77\x70\x2f\x66\x6c\x61\x67\x2f\x69\x6e\x66\x6f";
const LICENSE_VERSION = "\x31\x2e\x37\x2e\x30";
const LICENSE_ENDPOINT = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6c\x69\x63\x65\x6e\x73\x65\x2e\x77\x65\x6c\x74\x70\x69\x78\x65\x6c\x2e\x63\x6f\x6d";
/**
* @var string
*/
protected $_cacheTag = 'weltixel_license';
/**
* Prefix of model events names
*
* @var string
*/
protected $_eventPrefix = 'weltixel_license';
/**
* @var \Magento\Framework\App\DeploymentConfig
*/
protected $deploymentConfig;
/**
* @var \Magento\Framework\Component\ComponentRegistrarInterface
*/
protected $componentRegistrar;
/**
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
*/
protected $readFactory;
/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected $productMetadata;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $urlInterface;
/**
* @var array
*/
protected $existingLicenses;
/**
* @var null|string
*/
protected $pearlTheme = null;
/**
* @var array
*/
protected $modulesList = [];
/**
* @var array
*/
protected $modulesUserFriendlyNames = [];
/**
* @var array
*/
protected $_currentModulesList = [];
/**
* @var \Magento\Framework\App\Config\Storage\WriterInterface
*/
protected $configWriter;
/**
* @var array
*/
protected $_wpModulesList = [];
/**
* @var array
*/
protected $_wpBundleList = [];
/**
* @var int
*/
protected $_attempt = 0;
/**
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
* @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Magento\Framework\UrlInterface $urlInterface
* @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
* @param \Magento\Backend\Model\Session $backendSession
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\DeploymentConfig $deploymentConfig,
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar,
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
\Magento\Framework\UrlInterface $urlInterface,
\Magento\Framework\App\Config\Storage\WriterInterface $configWriter,
\Magento\Backend\Model\Session $backendSession
)
{
parent::__construct($context, $registry);
$this->deploymentConfig = $deploymentConfig;
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
$this->productMetadata = $productMetadata;
$this->urlInterface = $urlInterface;
$this->existingLicenses = null;
$this->configWriter = $configWriter;
$this->backendSession = $backendSession;
}
/**
* @return void
*/
protected function _construct()
{
$this->_init('WeltPixel\Backend\Model\ResourceModel\License');
}
/**
* Get identities
*
* @return array
*/
public function getIdentities()
{
return [self::CACHE_TAG . '_' . $this->getId(), self::CACHE_TAG . '_' . $this->getIdentifier()];
}
/**
* @return array
*/
protected function _getExistingLicenses()
{
$existingLicensesCollection = $this->getCollection();
foreach ($existingLicensesCollection as $licNs) {
$this->existingLicenses[$licNs->getModuleName()] = $licNs->getLicenseKey();
}
}
/**
* @param $mdN
* @return string
*/
public function getLfM($mdN)
{
if (!$this->existingLicenses) {
$this->_getExistingLicenses();
}
return (isset($this->existingLicenses[$mdN])) ? $this->existingLicenses[$mdN] : '-';
}
/**
* This might be changed to check inside each module if license is needed
* @return array
*/
public function getMdsL()
{
if (empty($this->_currentModulesList)) {
$modules = $this->deploymentConfig->get('modules');
$licenseModules = [];
$wpModules = [];
$moduleTheme = 'WeltPixel_Pearl_Startup';
$themePath = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::THEME, 'frontend/Pearl/weltpixel');
if ($themePath) {
$isLRqd = $this->_isLRqd($themePath, $moduleTheme);
$this->pearlTheme = $moduleTheme;
$lcK = '-';
if ($isLRqd) {
$lcK = $this->getLfM($moduleTheme);
$licenseModules[$moduleTheme] = [
"\x6d\x6f\x64\x75\x6c\x65\x5f\x6e\x61\x6d\x65" => $moduleTheme,
"\x76\x69\x73\x69\x62\x6c\x65\x5f\x6e\x61\x6d\x65" => (isset($this->modulesUserFriendlyNames[$moduleTheme]))
? $this->modulesUserFriendlyNames[$moduleTheme] : str_replace("_", " ", $moduleTheme) . ' Theme',
"\x6c\x69\x63\x65\x6e\x73\x65" => $lcK,
"\x76\x65\x72\x73\x69\x6f\x6e" => $this->getComposerVersion('frontend/Pearl/weltpixel', \Magento\Framework\Component\ComponentRegistrar::THEME)
];
}
$wpModules[$moduleTheme] = $this->getWpMdsInf($moduleTheme, $themePath, $lcK, $isLRqd, \Magento\Framework\Component\ComponentRegistrar::THEME);
}
foreach ($modules as $mdN => $isEnabled) {
if ($isEnabled && (strpos($mdN, 'WeltPixel_') !== false)
) {
$path = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, $mdN);
$bndFrmRst = $this->_vrfyBndFrm($path, $mdN);
if ($bndFrmRst['flag']) {
$this->_wpBundleList[$mdN] = $bndFrmRst['modules'];
}
}
}
foreach ($modules as $mdN => $isEnabled) {
if ($isEnabled && (strpos($mdN, 'WeltPixel_') !== false)
) {
$path = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, $mdN);
$lcK = '-';
$isLRqd = $this->_isLRqd($path, $mdN);
if ($isLRqd) {
$lcK = $this->getLfM($mdN);
$componentName = $mdN;
if (substr($mdN, -4) == "\x5f\x50\x72\x6f") {
$componentName = substr($mdN, 0, -4);
}
$licenseModules[$mdN] = [
"\x6d\x6f\x64\x75\x6c\x65\x5f\x6e\x61\x6d\x65" => $mdN,
"\x76\x69\x73\x69\x62\x6c\x65\x5f\x6e\x61\x6d\x65" => (isset($this->modulesUserFriendlyNames[$mdN]))
? $this->modulesUserFriendlyNames[$mdN] : str_replace("_", " ", $mdN),
"\x6c\x69\x63\x65\x6e\x73\x65" => $lcK,
"\x76\x65\x72\x73\x69\x6f\x6e" => $this->getComposerVersion(str_replace(["\x5f\x46\x72\x65\x65"], '', $componentName), \Magento\Framework\Component\ComponentRegistrar::MODULE)
];
}
$wpModules[$mdN] = $this->getWpMdsInf($mdN, $path, $lcK, $isLRqd, \Magento\Framework\Component\ComponentRegistrar::MODULE);
}
if ($isEnabled && (strpos($mdN, 'WeSupply_') !== false)
) {
$path = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, $mdN);
$lcK = '-';
$isLRqd = false;
$wpModules[$mdN] = $this->getWpMdsInf($mdN, $path, $lcK, $isLRqd, \Magento\Framework\Component\ComponentRegistrar::MODULE);
}
}
$this->_currentModulesList = $licenseModules;
$this->_wpModulesList = $wpModules;
}
return $this->_currentModulesList;
}
/**
* @param string $licNs
* @param string $mdN
* @return bool
*/
public function isLcVd($licNs, $mdN)
{
$magentoVersion = strtolower($this->productMetadata->getEdition());
if ($magentoVersion != "\x63\x6f\x6d\x6d\x75\x6e\x69\x74\x79") {
$magentoVersion = "\x65\x6e\x74\x65\x72\x70\x72\x69\x73\x65";
}
$constant = self::LICENSE_CONSTANT;
$baseUrl = $this->urlInterface->getBaseUrl();
$domain = $this->getDomainFromUrl($baseUrl);
$iv = substr(hash('sha256', self::LICENSE_IV), 0, 16);
try {
$licenseDecoded = openssl_decrypt($licNs, self::LICENSE_CIPHER, self::LICENSE_PASSWORD, 0, $iv);
} catch (\Exception $ex) {
return false;
}
$moduleInfo = $this->getMdInfVl($mdN);
if (!$moduleInfo) return false;
$licenseOptions = explode("|||", $licenseDecoded);
if (count($licenseOptions) != 5) return false;
if ($constant != $licenseOptions[4]) return false;
if ($mdN != $licenseOptions[1]) return false;
if (($magentoVersion != $licenseOptions[3]) && ($magentoVersion != "\x63\x6f\x6d\x6d\x75\x6e\x69\x74\x79")) return false;
return $this->checkDomainValidity($domain, $licenseOptions[2]);
}
/**
* @param $licNs
* @return array
*/
public function getLicenseDetails($licNs)
{
$iv = substr(hash('sha256', self::LICENSE_IV), 0, 16);
try {
$licenseDecoded = openssl_decrypt($licNs, self::LICENSE_CIPHER, self::LICENSE_PASSWORD, 0, $iv);
} catch (\Exception $ex) {
return [];
}
$licenseOptions = explode("|||", $licenseDecoded);
return $licenseOptions;
}
/**
* @param $domain
* @param $licenseDomain
* @return bool
*/
public function checkDomainValidity($domain, $licenseDomain)
{
$matches = [];
preg_match('/(.local|.localhost|.localdev|.dev|.development|.test|.staging|.stage|magentosite.cloud|magento.cloud|nxcli.net|nxcli.io)$/', $domain, $matches);
if (isset($matches[1])) {
if (($matches[1] == 'magentosite.cloud') || ($matches[1] == 'magento.cloud') || ($matches[1] == 'nxcli.net') || ($matches[1] == 'nxcli.io')) {
return true;
}
$findWhere = substr($licenseDomain, 0, strpos($licenseDomain, '.'));
$findMe = substr($domain, 0, strpos($domain, '.'));
if (strpos($findMe, $findWhere) !== false) {
return true;
}
}
if ($domain != $licenseDomain) return false;
return true;
}
/**
* @return string
*/
public function getMagentoVersion()
{
return strtolower($this->productMetadata->getEdition());
}
/**
* @return mixed|string
*/
public function getMagentoDomain()
{
$baseUrl = $this->urlInterface->getBaseUrl();
$domain = $this->getDomainFromUrl($baseUrl);
return $domain;
}
/**
* @param string $mdN
* @param string $licNs
* @return array|bool
*/
public function getMdLcnDtls($mdN, $licNs)
{
$constant = self::LICENSE_CONSTANT;
$iv = substr(hash('sha256', self::LICENSE_IV), 0, 16);
try {
$licenseDecoded = openssl_decrypt($licNs, self::LICENSE_CIPHER, self::LICENSE_PASSWORD, 0, $iv);
} catch (\Exception $ex) {
return false;
}
$licenseOptions = explode("|||", $licenseDecoded);
if (strpos($mdN, 'WeltPixel_Pearl_') !== false) {
$mdN = 'WeltPixel_Pearl';
}
if (count($licenseOptions) != 6) return false;
if ($constant != $licenseOptions[5]) return false;
if (strpos($licenseOptions[1], $mdN) === false) return false;
$details = [
"\x6d\x6f\x64\x75\x6c\x65" => $licenseOptions[1],
"\x69\x73\x5f\x74\x68\x65\x6d\x65\x5f\x6d\x6f\x64\x75\x6c\x65" => $licenseOptions[2],
"\x74\x68\x65\x6d\x65\x5f\x70\x61\x63\x6b\x61\x67\x65\x73" => explode(',', $licenseOptions[3]),
"\x69\x73\x5f\x6c\x69\x63\x65\x6e\x73\x65\x5f\x6e\x65\x65\x64\x65\x64" => $licenseOptions[4],
];
return $details;
}
/**
* @param string $mdN
* @param string $bndlInf
* @return array|bool
*/
public function getBndlFrmDtls($mdN, $bndlInf)
{
$constant = self::LICENSE_CONSTANT;
$iv = substr(hash('sha256', self::LICENSE_IV), 0, 16);
try {
$bundleInfDecoded = openssl_decrypt($bndlInf, self::LICENSE_CIPHER, self::LICENSE_PASSWORD, 0, $iv);
} catch (\Exception $ex) {
return false;
}
$bundleOptions = explode("|||", $bundleInfDecoded);
if (count($bundleOptions) != 4) return false;
if ($constant != $bundleOptions[3]) return false;
if (strpos($bundleOptions[1], $mdN) === false) return false;
return $bundleOptions[2];
}
/**
* @param $url
* @return mixed|string
*/
public function getDomainFromUrl($url)
{
$url = strtolower($url);
// regex can be replaced with parse_url
preg_match("/^(https|http|ftp):\/\/(.*?)\//", "$url/", $matches);
$parts = explode(".", $matches[2]);
$tld = array_pop($parts);
$tld = strtok($tld, ':');
$host = array_pop($parts);
$genericTlds = array(
'aero', 'asia', 'biz', 'cat', 'com', 'coop', 'info', 'int', 'jobs', 'mobi', 'museum', 'name', 'net',
'org', 'pro', 'tel', 'travel', 'xxx', 'edu', 'gov', 'mil', 'co'
);
if (strlen($tld) == 2 && strlen($host) <= 3 && (in_array($host, $genericTlds))) {
$tld = "$host.$tld";
$host = array_pop($parts);
}
$domain = ($host) ? $host . "." . $tld : $tld;
return $domain;
}
/**
* @param string $path
* @param string $mdN
* @return array
*/
protected function _vrfyBndFrm($path, $mdN) {
$result = [
'flag' => false
];
$directoryRead = $this->readFactory->create($path);
try {
$bndlInf = $directoryRead->readFile(self::BUNDLE_KEY_PATH);
} catch (\Exception $ex) {
return $result;
}
$bndlInfDtls = $this->getBndlFrmDtls($mdN, $bndlInf);
if (!$bndlInfDtls) return $result;
return [
'flag' => true,
'modules' => explode(',', $bndlInfDtls)
];
}
/**
* @param string $path
* @param string $mdN
* @param boolean $forced
* @return Boolean
*/
protected function _isLRqd($path, &$mdN, $forced = false)
{
$availableModules = $this->getAvlbMds();
if (!empty($availableModules) && !in_array($mdN, $availableModules)) {
return false;
}
$magentoVersion = strtolower($this->productMetadata->getEdition());
$directoryRead = $this->readFactory->create($path);
try {
$licNs = $directoryRead->readFile(self::LICENCE_KEY_PATH);
} catch (\Exception $ex) {
return true;
}
$moduleLicenseDetails = $this->getMdLcnDtls($mdN, $licNs);
if (!$moduleLicenseDetails) return true;
/** verificare pt modul la functionalitate de modul */
if ($forced) {
if ($moduleLicenseDetails['module'] != $mdN) {
return true;
}
/** ha tema modulja, tema license kell mukodjon */
if ($moduleLicenseDetails['is_theme_module']) {
$mdN = $this->pearlTheme;
return true;
}
/** tartalmazza a temat */
if ($this->pearlTheme) {
if (in_array($this->pearlTheme, $moduleLicenseDetails['theme_packages'])) {
$mdN = $this->pearlTheme;
return true;
}
} else {
if (!($moduleLicenseDetails['is_license_needed']) && ($magentoVersion == "\x63\x6f\x6d\x6d\x75\x6e\x69\x74\x79")) {
return false;
} else {
// logika a bundle csomagra
if (count($this->_wpBundleList)) {
$mdN = $this->_getBundleNameForModule($mdN, $this->_wpBundleList);
}
return true;
}
}
} else {
$mdN = $moduleLicenseDetails['module'];
/** tema sajat modulja */
if ($moduleLicenseDetails['is_theme_module']) {
return false;
}
if (!($moduleLicenseDetails['is_license_needed']) && ($magentoVersion == "\x63\x6f\x6d\x6d\x75\x6e\x69\x74\x79")) {
return false;
}
/** tartalmazza a temat */
if ($this->pearlTheme) {
if (in_array($this->pearlTheme, $moduleLicenseDetails['theme_packages'])) {
return false;
}
}
/** bundle csomag */
if ($this->_verifyModuleInBundleList($mdN, $this->_wpBundleList)) {
return false;
}
}
return true;
}
/**
* @param string $mdN
* @param array $wpBundleList
* @return bool
*/
private function _verifyModuleInBundleList($mdN, $wpBundleList) {
foreach ($wpBundleList as $bundleName => $modules) {
if (in_array($mdN, $modules)) {
return true;
}
}
return false;
}
/**
* @param string $mdN
* @param array $wpBundleList
* @return string
*/
private function _getBundleNameForModule($mdN, $wpBundleList) {
foreach ($wpBundleList as $bundleName => $modules) {
if (in_array($mdN, $modules)) {
return $bundleName;
}
}
return $mdN;
}
/**
* @return array
*/
protected function getAvlbMds()
{
$weltpixelExtensions = $this->backendSession->getWeltPixelExtensions();
$weltpixelExtensionsUserFriendlyNames = $this->backendSession->getWeltPixelExtensionsUserFriendlyNames();
if (!empty($weltpixelExtensions)) {
$this->modulesList = $weltpixelExtensions;
$this->modulesUserFriendlyNames = $weltpixelExtensionsUserFriendlyNames;
return $weltpixelExtensions;
}
if ($this->_attempt < 3 && empty($this->modulesList)) {
$curl = curl_init(\WeltPixel\Backend\Block\Adminhtml\ModulesVersion::MODULE_VERSIONS);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
try {
$response = curl_exec($curl);
$modulesList = json_decode($response, true);
$this->modulesList = array_keys($modulesList['modules']);
foreach ($this->modulesList as $module) {
if (isset($modulesList['modules'][$module]['name'])) {
$this->modulesUserFriendlyNames[$module] = $modulesList['modules'][$module]['name'];
}
}
$this->backendSession->setWeltPixelExtensions($this->modulesList);
$this->backendSession->setWeltPixelExtensionsUserFriendlyNames($this->modulesUserFriendlyNames);
} catch (\Exception $ex) {
$this->_attempt += 1;
$this->modulesList = [];
$this->modulesUserFriendlyNames = [];
}
}
if ($this->_attempt == 2) {
$this->backendSession->setWeltPixelExtensions(['WeltPixel_Backend']);
$this->backendSession->setWeltPixelExtensionsUserFriendlyNames(['WeltPixel_Backend']);
}
return $this->modulesList;
}
/**
* @return array
*/
public function getUserFriendlyModuleNames()
{
return $this->modulesUserFriendlyNames;
}
/**
* @param $mdN
* @return boolean
*/
public function isLcNd($mdN)
{
$this->getMdsL();
$componentName = $mdN;
if (substr($mdN, -4) == "\x5f\x50\x72\x6f") {
$componentName = substr($mdN, 0, -4);
}
$path = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, str_replace(["\x5f\x46\x72\x65\x65"], '', $componentName));
$isLRqd = $this->_isLRqd($path, $mdN, true);
if ($isLRqd) {
$licNs = $this->getLfM($mdN);
return $this->isLcVd($licNs, $mdN);
}
return true;
}
/**
* @param $mdN
* @return bool|string
*/
protected function getMdInfVl($mdN)
{
$connection = $this->getResource()->getConnection();
$tableName = $this->getResource()->getTable('core_config_data');
$row = $connection->fetchRow("SELECT `value` FROM " . $tableName . " WHERE path = '"
. self::LICENSE_INFO_PREFIX . "' AND scope = '"
. \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT
. "' AND scope_id = 0");
if (!isset($row['value']) || $row['value'] == 0) {
return true;
}
$row = $connection->fetchRow("SELECT `value` FROM " . $tableName . " WHERE path = '"
. self::MODULE_INFO_PREFIX . $mdN . "' AND scope = '"
. \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT
. "' AND scope_id = 0");
if (!isset($row['value'])) {
return true;
}
return $row['value'];
}
/**
* @param $mdN
* @return string
*/
protected function getComposerVersion($mdN, $type)
{
$path = $this->componentRegistrar->getPath(
$type,
$mdN
);
if (!$path) {
return __('N/A');
}
$dirReader = $this->readFactory->create($path);
$composerJsonData = $dirReader->readFile('composer.json');
$data = json_decode($composerJsonData, true);
return isset($data['version']) ? $data['version'] : null;
}
/**
* @param string $mdN
* @param string $path
* @param string $licNs
* @param boolean $isLNd
* @return array
*/
protected function getWpMdsInf($mdN, $path, $licNs, $isLNd, $moduleType)
{
$installationType = 'other';
if (strpos($path, 'vendor') !== false) {
$installationType = 'composer';
}
$moduleVersionName = $mdN;
if ($moduleType == \Magento\Framework\Component\ComponentRegistrar::THEME) {
$moduleVersionName = 'frontend/Pearl/weltpixel';
}
$vLid = false;
if ($isLNd) {
$vLid = $this->isLcVd($licNs, $mdN);
}
$componentName = $moduleVersionName;
if (substr($moduleVersionName, -4) == "\x5f\x50\x72\x6f") {
$componentName = substr($moduleVersionName, 0, -4);
}
return [
"\x6e\x61\x6d\x65" => $mdN,
"\x76\x65\x72\x73\x69\x6f\x6e" => $this->getComposerVersion(str_replace(["\x5f\x46\x72\x65\x65"], '', $componentName), $moduleType),
"\x6c\x69\x63\x65\x6e\x73\x65\x5f\x6b\x65\x79" => $licNs,
"\x69\x6e\x73\x74\x61\x6c\x6c\x61\x74\x69\x6f\x6e\x5f\x74\x79\x70\x65" => $installationType,
"\x69\x73\x5f\x6c\x69\x63\x65\x6e\x73\x65\x5f\x6e\x65\x65\x64\x65\x64" => ($isLNd) ? '1' : '0',
"\x76\x61\x6c\x69\x64" => ($vLid) ? '1' : '0'
];
}
/**
* @return array
*/
public function getAllWpMds()
{
$this->getMdsL();
return $this->_wpModulesList;
}
/**
* @param string $mdN
*/
public function updMdInf($mdN)
{
$this->getMdsL();
$modules = [];
$moduleInformation = $this->_wpModulesList[$mdN];
$modules[$mdN] = $moduleInformation;
$this->updMdsInf(false, $modules);
}
/**
* @param bool $all
* @param array $modules
*/
public function updMdsInf($all = true, $modules = [])
{
if ($all) {
$modules = $this->getAllWpMds();
}
$baseUrl = $this->urlInterface->getBaseUrl();
$domainInfo = parse_url($baseUrl);
$domain = $domainInfo['host'];
$magentoVersion = strtolower($this->productMetadata->getEdition());
$magentoVersionNumber = $this->productMetadata->getVersion();
$phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION; //phpversion();
$data = array(
"\x76\x65\x72\x73\x69\x6f\x6e" => $magentoVersion,
"\x76\x65\x72\x73\x69\x6f\x6e\x5f\x6e\x75\x6d\x62\x65\x72" => $magentoVersionNumber,
"\x64\x6f\x6d\x61\x69\x6e" => $domain,
"\x70\x68\x70\x5f\x76\x65\x72\x73\x69\x6f\x6e" => $phpVersion,
"\x6d\x6f\x64\x75\x6c\x65\x73" => $modules
);
$data_string = json_encode($data);
try {
$ch = curl_init(self::LICENSE_ENDPOINT);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
$this->_prsLcInf($result);
} catch (\Exception $ex) {
$this->_uLcInRs(0);
}
}
/**
* @param $result
*/
protected function _prsLcInf($result)
{
$info = json_decode($result, true);
if (!is_array($info)) {
$this->_uLcInRs(0);
return;
}
foreach ($info as $mName => $val) {
$this->configWriter->save(self::MODULE_INFO_PREFIX . $mName, $val, \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
}
$this->_uLcInRs(1);
}
/**
* @param $flag
*/
protected function _uLcInRs($flag)
{
$this->configWriter->save(self::LICENSE_INFO_PREFIX, $flag, \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
}
}
@@ -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;
}
}
@@ -0,0 +1,19 @@
<?php
namespace WeltPixel\Backend\Model\ResourceModel;
/**
* Class License
* @package WeltPixel\Backend\Model\ResourceModel
*/
class License extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('weltpixel_license', 'id');
}
}
@@ -0,0 +1,24 @@
<?php
namespace WeltPixel\Backend\Model\ResourceModel\License;
/**
* Class Collection
* @package WeltPixel\Backend\Model\ResourceModel\License
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* @var string
*/
protected $_idFieldName = 'id';
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('WeltPixel\Backend\Model\License', 'WeltPixel\Backend\Model\ResourceModel\License');
}
}
@@ -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,46 @@
<?php
namespace WeltPixel\Backend\Observer;
use Magento\Framework\Event\ObserverInterface;
/**
* AdminLoginSuccessObserver observer
*
*/
class AdminLoginSuccessObserver implements ObserverInterface
{
/**
* @var \WeltPixel\Backend\Helper\License
*/
protected $wpHelper;
/**
* @var \Magento\Backend\Model\Session
*/
protected $session;
/**
* @param \WeltPixel\Backend\Helper\License $wpHelper
* @param \Magento\Backend\Model\Session $session
*/
public function __construct(
\WeltPixel\Backend\Helper\License $wpHelper,
\Magento\Backend\Model\Session $session
) {
$this->wpHelper = $wpHelper;
$this->session = $session;
}
/**
* @param \Magento\Framework\Event\Observer $observer
* @return self
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$this->session->setWeltPixelExtensions(null);
$this->session->setWeltPixelExtensionsUserFriendlyNames(null);
$this->wpHelper->checkAndUpdate();
$this->wpHelper->updMdsInf();
return $this;
}
}
@@ -0,0 +1,101 @@
<?php
namespace WeltPixel\Backend\Observer;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Event\ObserverInterface;
/**
* PredispatchAdminActionControllerObserver observer
*
*/
class PredispatchAdminActionControllerObserver implements ObserverInterface
{
const XML_PATH_WELTPIXEL_ENABLE_ADMIN_NOTIFICATIONS = 'weltpixel_backend_developer/notifications/enable_admin_notification';
/**
* @var \WeltPixel\Backend\Model\FeedFactory
*/
protected $_feedFactory;
/**
* @var \Magento\Backend\Model\Auth\Session
*/
protected $_backendAuthSession;
/**
* @var \Magento\Framework\Message\ManagerInterface
*/
protected $messageManager;
/**
* @var \WeltPixel\Backend\Helper\License
*/
protected $wpHelper;
/**
* @var ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* @param \WeltPixel\Backend\Model\FeedFactory $feedFactory
* @param \Magento\Backend\Model\Auth\Session $backendAuthSession
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \WeltPixel\Backend\Helper\License $wpHelper
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
\WeltPixel\Backend\Model\FeedFactory $feedFactory,
\Magento\Backend\Model\Auth\Session $backendAuthSession,
\Magento\Framework\Message\ManagerInterface $messageManager,
\WeltPixel\Backend\Helper\License $wpHelper,
ScopeConfigInterface $scopeConfig
) {
$this->_feedFactory = $feedFactory;
$this->_backendAuthSession = $backendAuthSession;
$this->messageManager = $messageManager;
$this->wpHelper = $wpHelper;
$this->_scopeConfig = $scopeConfig;
}
/**
* Predispath admin action controller
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Framework\App\Request\Http $request */
$request = $observer->getData('request');
$routeName = $request->getRouteName();
if (in_array($routeName, ['tfa'])) {
return $this;
}
$isNotificationEnabled = $this->_scopeConfig->getValue(self::XML_PATH_WELTPIXEL_ENABLE_ADMIN_NOTIFICATIONS);
if ($isNotificationEnabled && $this->_backendAuthSession->isLoggedIn()) {
$feedModel = $this->_feedFactory->create();
/* @var $feedModel \WeltPixel\Backend\Model\Feed */
$feedModel->checkUpdate();
$licenseMessage = $this->wpHelper->getLicenseMessage();
if ($licenseMessage) {
$items = $this->messageManager->getMessages(false)->getItems();
$errorAlreadyAdded = false;
foreach ($items as $item) {
if ($item->getText() == $licenseMessage) {
$errorAlreadyAdded = true;
}
}
if (!$errorAlreadyAdded) {
$this->messageManager->addError($licenseMessage);
}
}
}
return $this;
}
}
@@ -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;
}
}
@@ -0,0 +1,23 @@
<?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;
}
}
@@ -0,0 +1,134 @@
<?php
namespace WeltPixel\Backend\Plugin;
class Utility
{
/**
* @var \Magento\Framework\App\ResponseInterface
*/
protected $_response;
/**
* @var \Magento\Framework\App\ViewInterface
*/
protected $_view;
/**
* @var \Magento\Backend\Model\Auth
*/
protected $_auth;
/**
* @var string
*/
protected $_pathInfo;
/** @var \WeltPixel\Backend\Model\License */
protected $licenseModel;
/**
* @param \Magento\Backend\Model\Auth $auth
* @param \Magento\Framework\App\ResponseInterface $response
* @param \Magento\Framework\App\ViewInterface $view
* @param \WeltPixel\Backend\Model\License $licenseModel
*/
public function __construct(
\Magento\Backend\Model\Auth $auth,
\Magento\Framework\App\ResponseInterface $response,
\Magento\Framework\App\ViewInterface $view,
\WeltPixel\Backend\Model\License $licenseModel
)
{
$this->_auth = $auth;
$this->_response = $response;
$this->_view = $view;
$this->licenseModel = $licenseModel;
}
/**
* @param \Magento\Backend\App\AbstractAction $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(
\Magento\Backend\App\AbstractAction $subject,
\Closure $proceed,
\Magento\Framework\App\RequestInterface $request
)
{
$this->_pathInfo = $request->getPathInfo();
if ($this->_auth->isLoggedIn() && !$request->isAjax() && $this->_isPathRestrictionRequired() && $request->isDispatched() && !$this->_isLcVd()) {
$this->_response->setStatusHeader(403, '1.1', 'Forbidden');
$this->_view->loadLayout(['default', 'weltpixel_license_needed'], true, true, false);
$this->_view->renderLayout();
$request->setDispatched(true);
return $this->_response;
}
return $proceed($request);
}
/**
* @return string
*/
protected function getPathInfo()
{
return $this->_pathInfo;
}
/**
* @return bool
*/
protected function _isLcVd()
{
$moduleName = $this->getModuleName();
$isLicenseRequired = $this->licenseModel->isLcNd($moduleName);
return $isLicenseRequired;
}
/**
* @return string
*/
protected function getModuleName() {
return '';
}
/**
* @return bool
*/
protected function _isPathRestrictionRequired()
{
foreach ($this->_getAdminPaths() as $path) {
if (strpos($this->getPathInfo(), $path) !== false) {
return true;
}
}
return false;
}
/**
* @return array
*/
protected function _getAdminPaths()
{
return [];
}
/**
* @param array $chars
* @return string
*/
public function convertToString($chars) {
return implode(array_map('chr', $chars));
}
}
+24
View File
@@ -0,0 +1,24 @@
# m2-weltpixel-backend
### Installation
With composer:
```sh
$ composer config repositories.welpixel-m2-weltpixel-backend git git@github.com:Weltpixel/m2-weltpixel-backend.git
$ composer require weltpixel/m2-weltpixel-backend:dev-master
```
Note: Composer installation only available for WeltPixel internal use for the moment as the repositos are not public. However, there is a work around that will allow you to install the product via composer, described in the article below: https://support.weltpixel.com/hc/en-us/articles/115000216654-How-to-use-composer-and-install-Pearl-Theme-or-other-WeltPixel-extensions
Manually:
Copy the zip into 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 [];
}
}
+21
View File
@@ -0,0 +1,21 @@
{
"name": "weltpixel/m2-weltpixel-backend",
"description": "WeltPixel Backend Module",
"require": {
"magento/module-admin-notification": "*"
},
"type": "magento2-module",
"version": "1.11.19",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"WeltPixel\\Backend\\": ""
}
}
}
+36
View File
@@ -0,0 +1,36 @@
<?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_Documentation" title="WeltPixel Documentation" sortOrder="0" />
<resource id="WeltPixel_Backend::WeltPixel_HelpCenter" title="WeltPixel HelpCenter" sortOrder="2" />
<resource id="WeltPixel_Backend::WeltPixel_Licenses" title="WeltPixel Licenses" sortOrder="3" >
<resource id="WeltPixel_Backend::Modules_License" title="Licenses" sortOrder="10" />
</resource>
<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>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch">
<observer name="weltpixel_backend" instance="WeltPixel\Backend\Observer\PredispatchAdminActionControllerObserver" />
</event>
<event name="backend_auth_user_login_success">
<observer name="weltpixel_backend_admin_login_successs" instance="WeltPixel\Backend\Observer\AdminLoginSuccessObserver" />
</event>
</config>
@@ -0,0 +1,90 @@
<?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_Documentation"
title="WeltPixel Documentation"
module="WeltPixel_Backend"
action="adminhtml/system_config/edit/section/weltpixel_backend_config/"
sortOrder="0"
parent="WeltPixel_Backend::WeltPixel"
resource="WeltPixel_Backend::WeltPixel_Documentation"
/>
<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_Licenses"
title="WeltPixel Licenses"
module="WeltPixel_Backend"
sortOrder="2"
parent="WeltPixel_Backend::WeltPixel"
resource="WeltPixel_Backend::WeltPixel_Licenses"
/>
<add
id="WeltPixel_Backend::Modules_License"
title="Modules Licenses"
module="WeltPixel_Backend"
action="weltpixel_backend/licenses/index"
sortOrder="2"
parent="WeltPixel_Backend::WeltPixel_Licenses"
resource="WeltPixel_Backend::Modules_License"
/>
<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_Modules"
title="Extensions Version"
module="WeltPixel_Backend"
action="weltpixel_backend/debugger/modules"
sortOrder="5"
parent="WeltPixel_Backend::WeltPixel_Debugger"
resource="WeltPixel_Backend::WeltPixel_Debugger_Modules"
/>z
<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>
@@ -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>
@@ -0,0 +1,58 @@
<?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_config" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>WeltPixel Documentation</label>
<tab>weltpixel</tab>
<class>item-weltpixel-documentation</class>
<resource>WeltPixel_Backend::DocumentationSettings</resource>
<group id="recommended_solutions" translate="label" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Recommended Solutions:</label>
<frontend_model>WeltPixel\Backend\Block\Adminhtml\System\Config\Extensions</frontend_model>
</group>
</section>
<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="notifications" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Notifications</label>
<field id="enable_admin_notification" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable WeltPixel Admin Notifications</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Enable to receive notifications about important Product Updates via the Magento Admin.</comment>
</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>
+19
View File
@@ -0,0 +1,19 @@
<?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>
<notifications>
<enable_admin_notification>1</enable_admin_notification>
</notifications>
<csp>
<change_system_value>0</change_system_value>
<report_only>1</report_only>
</csp>
</weltpixel_backend_developer>
<weltpixel>
<crontab>
<license>5 4 * * 0</license>
</crontab>
</weltpixel>
</default>
</config>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job name="weltpixel_backend_moduleinfoupdate" instance="WeltPixel\Backend\Cron\ModuleInfoUpdate" method="execute" >
<config_path>weltpixel/crontab/license</config_path>
</job>
</group>
</config>
@@ -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>
@@ -0,0 +1 @@
yDH54Xmc8ZMWihgGLTGdvfRGHHSOqm5yLMepbNdc2GXp2NkaKK9+wB1H3Xd2gbgagVRQmzifTWIFNxUke4GhVyu09WBujayaEAW3/CjSpvD+7NVL73TTDAzzpe9Y9+qH8HLuGCyNfEoV7a7sEEE9D/DNaHz/6wZAFP+YpxP2U3J9WkvnYc+LH4OEJPVluWq4
@@ -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>
+56
View File
@@ -0,0 +1,56 @@
"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
"The license key was successfully updated.","The license key was successfully updated."
"The license key introduced is valid","The license key introduced is valid"
"The license key you entered is invalid.","The license key you entered is invalid."
"Common reasons:","Common reasons:"
"- Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc..","- Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc.."
"- Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation.","- Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation."
"- Wrong module - using a license key from a different product or product pack.","- Wrong module - using a license key from a different product or product pack."
"There was a problem with the license key saving.","There was a problem with the license key saving."
"License missing or invalid for the following WeltPixel module(s):","License missing or invalid for the following WeltPixel module(s):"
"You can enter the license key(s)","You can enter the license key(s)"
here.,here.
"License key can be found under My Downloadable Products section of your weltpixel.com account.","License key can be found under My Downloadable Products section of your weltpixel.com account."
"Yes (Recommended)","Yes (Recommended)"
No,No
"Sorry, you need a valid license key to view this content.","Sorry, you need a valid license key to view this content."
"Next steps","Next steps"
"If you think this is an error, make sure you added the correct license.","If you think this is an error, make sure you added the correct license."
"Check Here","Check Here"
"Contact us if the problem still persists.","Contact us if the problem still persists."
Name,Name
"License Key","License Key"
Submit,Submit
"No licenses needed for current Weltpixel installed extensions.","No licenses needed for current Weltpixel installed extensions."
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"
Notifications,Notifications
"Enable WeltPixel Admin Notifications","Enable WeltPixel Admin Notifications"
"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 The license key was successfully updated. The license key was successfully updated.
13 The license key introduced is valid The license key introduced is valid
14 The license key you entered is invalid. The license key you entered is invalid.
15 Common reasons: Common reasons:
16 - Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc.. - Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc..
17 - Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation. - Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation.
18 - Wrong module - using a license key from a different product or product pack. - Wrong module - using a license key from a different product or product pack.
19 There was a problem with the license key saving. There was a problem with the license key saving.
20 License missing or invalid for the following WeltPixel module(s): License missing or invalid for the following WeltPixel module(s):
21 You can enter the license key(s) You can enter the license key(s)
22 here. here.
23 License key can be found under My Downloadable Products section of your weltpixel.com account. License key can be found under My Downloadable Products section of your weltpixel.com account.
24 Yes (Recommended) Yes (Recommended)
25 No No
26 Sorry, you need a valid license key to view this content. Sorry, you need a valid license key to view this content.
27 Next steps Next steps
28 If you think this is an error, make sure you added the correct license. If you think this is an error, make sure you added the correct license.
29 Check Here Check Here
30 Contact us if the problem still persists. Contact us if the problem still persists.
31 Name Name
32 License Key License Key
33 Submit Submit
34 No licenses needed for current Weltpixel installed extensions. No licenses needed for current Weltpixel installed extensions.
35 Enabled Enabled
36 Current Version Current Version
37 Latest Version Latest Version
38 Theme module Theme module
39 Themes Themes
40 WeltPixel WeltPixel
41 WeltPixel Documentation WeltPixel Documentation
42 Recommended Solutions: Recommended Solutions:
43 Developer Developer
44 System Information System Information
45 Logs Logs
46 Enable broken reference logs Enable broken reference logs
47 Notifications Notifications
48 Enable WeltPixel Admin Notifications Enable WeltPixel Admin Notifications
49 Content Security Policies Content Security Policies
50 Change Magento Default Mode Change Magento Default Mode
51 Only available from 2.3.5 version. Only available from 2.3.5 version.
52 Report Only Report Only
53 Area Area
54 Original Class Original Class
55 Rewrite Class Rewrite Class
56 Status Status
@@ -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,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">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<block class="WeltPixel\Backend\Block\Adminhtml\ModulesVersion" name="weltpixel_rewrites_modulesversion" template="WeltPixel_Backend::modules.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,14 @@
<?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"/>
<head>
<title>
WeltPixel Licenses
</title>
</head>
<body>
<referenceContainer name="content">
<block class="WeltPixel\Backend\Block\Adminhtml\Licenses" name="weltpixel_licenses" template="WeltPixel_Backend::licenses/list.phtml" />
</referenceContainer>
</body>
</page>
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<title>WeltPixel License Key Needed</title>
</head>
<body>
<referenceContainer name="content">
<block class="WeltPixel\Backend\Block\Adminhtml\Licenses" name="license.needed" template="WeltPixel_Backend::licenses/license_needed.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,11 @@
<div>
<input type="hidden" name="wp_base_url_jscolor" id="wp_base_url_jscolor" value="<?php echo $this->getViewFileUrl('WeltPixel_Backend::jscolor'); ?>" />
</div>
<script>
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,19 @@
<?php
// @codingStandardsIgnoreFile
?>
<?php
/**
* @see \WeltPixel\Backend\Block\Adminhtml\Licenses
*/
?>
<hr class="access-denied-hr"/>
<div class="access-denied-page">
<h2 class="page-heading"><?= $block->escapeHtml(__('Sorry, you need a valid license key to view this content.')) ?></h2>
<strong><?= $block->escapeHtml(__('Next steps')) ?></strong>
<ul>
<li><span><?= $block->escapeHtml(__('If you think this is an error, make sure you added the correct license.')) ?>
<a href="<?= $block->getLicensesUrl() ?>"><?= $block->escapeHtml(__('Check Here'));?></a>
</span></li>
<li><span><?= $block->escapeHtml(__('Contact us if the problem still persists.')) ?></span></li>
</ul>
</div>
@@ -0,0 +1,86 @@
<?php
$_helper = $this->helper('WeltPixel\Backend\Helper\License');
$licenseNeeded = $_helper->getModulesListForDisplay();
$odd = false;
?>
<?php if (count($licenseNeeded)) : ?>
<div class="license-container">
<table class="admin__table-secondary">
<thead>
<tr>
<th class="license-name"><?php echo __('Name'); ?></th>
<th class="license-key"><?php echo __('License Key'); ?></th>
<th class="license-validity"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<?php foreach ($licenseNeeded as $key => $options) : ?>
<?php $odd = !$odd; ?>
<form action="<?php echo $this->getLicensePostUrl()?>" method="post" data-mage-init='{"validation": {"errorClass": "mage-error"}}' >
<table class="admin__table-secondary <?php if ($odd) echo 'admin_table_filled' ?>">
<tbody>
<?php $licenseValidity = $_helper->isLcVd($options['license'], $options['module_name']); ?>
<tr>
<td class="license-name"><?php echo $options['visible_name'] ?></td>
<td class="license-key"><?php echo $options['license'] ?></td>
<td class="license-validity"><span class="license-status license-status-<?php echo ($licenseValidity) ? 'ok' : 'nok'; ?>"><?php echo ($licenseValidity) ? __('Valid') : __('Invalid') ?></span></td>
</tr>
<tr>
<td></td>
<td>
<input type="hidden" value="<?php echo $block->getFormKey(); ?>" name="form_key" />
<input type="hidden" name="module_name" value="<?php echo $options['module_name'] ?>" />
<input type="text" class="license-input" name="license" value="" data-validate="{required:true}" />
<button title="Submit" type="submit" class="primary submit-license-btn" role="button" disabled="disabled">
<span class="ui-button-text">
<span><?php echo __('Submit'); ?></span>
</span>
</button>
</td>
<td></td>
</tr>
</tbody>
</table>
</form>
<?php endforeach; ?>
</div>
<script>
requirejs(['jquery', 'Magento_Ui/js/modal/alert', 'domReady!'],
function ($, alert) {
setTimeout(function(){ $('.submit-license-btn').prop('disabled', false); }, 1000);
$('.submit-license-btn').click(function () {
var formToSubmit = $(this).closest("form");
if (formToSubmit.valid()) {
var that = this;
$(that).prop('disabled', true);
$.ajax({
type: formToSubmit.attr('method'),
url: formToSubmit.attr('action'),
data: formToSubmit.serialize(),
success: function (data) {
$(that).prop('disabled', false);
if (!data.error) {
formToSubmit.find('.license-key').html(data.license);
formToSubmit.find('.license-validity .license-status').removeClass('license-status-ok license-status-nok').addClass(data.is_valid);
formToSubmit.find('.license-validity .license-status').html(data.is_valid_msg);
formToSubmit.find('.license-input').val('');
}
alert({
title: '',
content: data.message
});
}
});
}
return false;
});
});
</script>
<?php else : ?>
<div>
<p><?php echo __('No licenses needed for current Weltpixel installed extensions.'); ?></p>
</div>
<?php endif; ?>
@@ -0,0 +1,38 @@
<script>
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,66 @@
<?php
$modules = $this->getModuleVersions();
$themes = $this->getThemeVersions();
?>
<div class="admin__page-section-item">
<div class="admin__page-section-item-content">
<table class="admin__table-secondary">
<thead>
<tr>
<th><?php echo __('Name'); ?></th>
<th><?php echo __('Enabled'); ?></th>
<th><?php echo __('Current Version'); ?></th>
<th><?php echo __('Latest Version'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($modules as $moduleName => $options) : ?>
<tr>
<td>
<span class="module-title"><?php echo $moduleName ?></span>
<?php if ($options['theme_module']) : ?>
<span class="module-theme-info">(<?php echo __('Theme module'); ?>)</span>
<?php endif; ?>
</td>
<td><?php echo ($options['enabled']) ? 'Yes' : 'No' ?></td>
<td><?php echo $options['version'] ?></td>
<td><?php echo $options['latest_version'] ?></td>
<td><span class="rewrite-status rewrite-status-<?php echo ($options['status']) ? 'ok' : 'nok'; ?>"><?php echo $options['status_message'] ?></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php if (count($themes)) : ?>
<hr/><br/>
<div class="admin__page-section-item">
<div class="admin__page-section-item-title">
<h1 class="page-title"><?php echo __('Themes'); ?></h1>
</div>
<div class="admin__page-section-item-content">
<table class="admin__table-secondary">
<thead>
<tr>
<th><?php echo __('Name'); ?></th>
<th><?php echo __('Current Version'); ?></th>
<th><?php echo __('Latest Version'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($themes as $themeName => $options) : ?>
<tr>
<td><span class="module-title"><?php echo $themeName ?></span></td>
<td><?php echo $options['version'] ?></td>
<td><?php echo $options['latest_version'] ?></td>
<td><span class="rewrite-status rewrite-status-<?php echo ($options['status']) ? 'ok' : 'nok'; ?>"><?php echo $options['status_message'] ?></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
@@ -0,0 +1,64 @@
<?php
/** @var \WeltPixel\Backend\Helper\Developer $developerHelper */
$developerHelper = $this->helper('WeltPixel\Backend\Helper\Developer');
$cronjoblimit = 100;
$scheduleCollection = $developerHelper->getLatestCronJobs($cronjoblimit);
?>
<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 ucfirst($this->getMagentoMode()); ?></div>
<div class="col-xs-6 information-label">Magento Installation Path</div>
<div class="col-xs-6"><?php echo $this->getMagentoPath(); ?></div>
<div class="col-xs-6 information-label">Magento Edition</div>
<div class="col-xs-6"><?php echo $developerHelper->getMagentoEdition(); ?></div>
<div class="col-xs-6 information-label">PHP Version</div>
<div class="col-xs-6"><?php echo phpversion() ?></div>
<div class="col-xs-6 information-label">Server User</div>
<div class="col-xs-6"><?php echo $developerHelper->getCurrentServerUser(); ?></div>
<div class="col-xs-6 information-label">Server User Group</div>
<div class="col-xs-6"><?php echo $developerHelper->getCurrentServerUserGroup(); ?></div>
<div class="col-xs-6 information-label">Current Time</div>
<div class="col-xs-6"><?php echo $developerHelper->getServerTime(); ?></div>
<div class="col-xs-6 information-label">Latest Cron Jobs (<?php echo $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 echo $item->getJobCode(); ?> </td>
<td class="status"><?php echo $item->getStatus(); ?> </td>
<td class="created-at"><?php echo $item->getCreatedAt(); ?> </td>
<td class="scheduled-at"><?php echo $item->getScheduledAt(); ?> </td>
<td class="executed-at"><?php echo ($item->getExecutedAt()) ? $item->getExecutedAt() : '-' ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<script>
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,305 @@
@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;
}
}
@@ -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,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,48 @@
<?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;
}
}
@@ -0,0 +1,240 @@
<?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;
use Magento\Customer\Model\Session;
use WeltPixel\LayeredNavigation\Block\Navigation\FilterRenderer;
/**
* 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 \WeltPixel\LayeredNavigation\Model\AttributeOptions
*/
protected $_attributeOptions;
/**
* 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 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,
protected Session $customerSession,
array $data = []
)
{
$this->_catalogLayer = $layerResolver->get();
$this->filterList = $filterList;
$this->visibilityFlag = $visibilityFlag;
$this->_productListHelper = $productListHelper;
$this->_wpHelper = $wpHelper;
$this->_attributeOptions = $attributeOptions;
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();
}
/**
* check if current filter is a category filter
*
* @param $filter
* @return bool
*/
public function isCategoryFilter($filter)
{
return ($filter->getRequestVar() == 'cat') ? 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);
}
/**
* set filter tab status
*
* @return string
*/
public function getActiveFilters() {
$filters = $this->getFilters();
$activeFilters = [];
$ctr = 0;
foreach($filters as $k => $filter) {
if($filter->getRequestVar() == 'cat') {
if($filter->getItemsCount()) $ctr++;
continue;
} else {
if($filter->getItemsCount()) {
$attributeId = $filter->getAttributeModel()->getAttributeId();
if($attributeId) {
$wpOptions = $this->getWpAttributeOptions($attributeId);
if($wpOptions->getData()) {
if($wpOptions->getDisplayOption() == '1' || $wpOptions->getDisplayOption() == '2') {
$activeFilters[] = $ctr;
}
}
}
$ctr++;
}
}
}
$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;
}
public function getRedirectUrl()
{
$redirectUrl = $this->customerSession->getData(FilterRenderer::CATEGORY_OPTION_REDIRECT_URL_KEY);
$this->customerSession->getData(FilterRenderer::CATEGORY_OPTION_REDIRECT_URL_KEY, true);
return $redirectUrl;
}
}
@@ -0,0 +1,178 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block\Navigation;
use Magento\Customer\Model\Session;
use Magento\Eav\Model\Config;
use Magento\Framework\View\Element\Template;
/**
* 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;
const CATEGORY_OPTION_REDIRECT_URL_KEY = 'category_option_redirect_url';
/**
* FilterRenderer constructor.
* @param \WeltPixel\LayeredNavigation\Helper\Data $wpHelper
* @param \WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions
* @param Template\Context $context
* @param array $data
*/
public function __construct(
\WeltPixel\LayeredNavigation\Helper\Data $wpHelper,
\WeltPixel\LayeredNavigation\Model\AttributeOptions $attributeOptions,
Template\Context $context,
protected Config $eavConfig,
protected Session $customerSession,
array $data = []
)
{
$this->_wpHelper = $wpHelper;
$this->_attributeOptions = $attributeOptions;
parent::__construct($context, $data);
}
/**
* @param $filter
*/
public function setAttributeId($filter)
{
$this->_attributeId = ($filter->getRequestVar() != 'cat') ? $filter->getAttributeModel()->getAttributeId() : 0;
}
/**
* 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 > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getShowQuantity();
} else {
return '';
}
}
return '';
}
/**
* return the 'Is Multiselect' attribute configuration value
*
* @return mixed
*/
public function getIsMultiSelect()
{
if ($this->_attributeId > 0) {
$attributeOptions = $this->getWpAttributeOptions();
if ($attributeOptions) {
return $attributeOptions->getIsMultiselect();
} else {
return '';
}
}
return '';
}
public function getAttribute()
{
return $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $this->_attributeId);
}
public function setRedirectUrl(string $url)
{
$this->customerSession->setData(self::CATEGORY_OPTION_REDIRECT_URL_KEY, $url);
return $this;
}
}
@@ -0,0 +1,51 @@
<?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 string
*/
protected $_template = 'WeltPixel_LayeredNavigation::layer/state.phtml';
/**
* 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);
}
}
@@ -0,0 +1,25 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayeredNavigation\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
/**
* Class Disable
* @package WeltPixel\LayerdNavigation\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,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.
@@ -0,0 +1,200 @@
<?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 FILTER_TYPE_SLIDER = 'slider';
const FILTER_TYPE_LIST = 'list';
const SLIDE_IN_STYLE = 1;
const FILTER_BUTTON_LABEL = 'Filter';
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
*/
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 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 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 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);
}
/**
* Filter Button option
* 0-icon only
* 1-icon & label
* 2-label only
*
* @return \Magento\Framework\Phrase|string
*/
public function getFilterButtonStyle()
{
switch ($this->getFilterButton()) {
case 0:
$filterButtonHtml = "<b class='wp-slide-in'></b>";
break;
case 1:
$filterButtonHtml = "<b class='wp-slide-in'></b><b class='wp-filters-text'>" . /* @escapeNotVerified */
__(self::FILTER_BUTTON_LABEL) . "</b>";
break;
case 2:
$filterButtonHtml = __(self::FILTER_BUTTON_LABEL);
break;
default:
$filterButtonHtml = '';
}
return $filterButtonHtml;
}
/**
* 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' ) {
return true;
}
return false;
}
/**
* Check the engine provider is 'elasticsearch' or 'opensearch'
* @deprecated
*
* @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;
}
}
@@ -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,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 SidebarStyle
* @package WeltPixel\LayeredNavigation\Model\Config\Source
*/
class SidebarStyle implements ArrayInterface
{
/**
* @var array
*/
protected $_styles = array(
'0' => 'Default',
'1' => 'Slide In',
);
/**
* @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 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,271 @@
<?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;
/**
* 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 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\Filter\StripTags $tagFilter,
\Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory $filterAttributeFactory,
LayerHelper $moduleHelper,
LayerFilter $layerFilter,
AttributeOptions $attributeOptions,
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;
}
/**
* @inheritdoc
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_moduleHelper->isEnabled()) {
return parent::apply($request);
}
$attribute = $this->getAttributeModel();
$attributeValue = $request->getParam($this->_requestVar);
if (empty($attributeValue)) {
$this->_isFilter = false;
return $this;
}
$this->_requestParamVal = $this->_requestVar;
$attributeValue = explode(',', $attributeValue);
$state = $this->getLayer()->getState();
foreach ($attributeValue as $value) {
$label = $this->getOptionText($value);
$state->addFilter($this->_createItem($label, $value));
}
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 parent::_getItemsData();
}
$logger = \Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
$attribute = $this->getAttributeModel();
$wpLnAttributeOptions = ($attribute->getId()) ? $this->_wpAttributeOptions->getDisplayOptionsByAttribute($attribute->getId()) : false;
if(!$wpLnAttributeOptions->getIsMultiselect() && $this->_isFilter && $attribute->getAttributeCode() != 'category_option') {
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"]);
}
}
@@ -0,0 +1,152 @@
<?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);
if ($this->dataProvider->isValid()) {
$category = $this->dataProvider->getCategory();
if ($request->getParam('id') != $id) {
$categoryIds[] = $id;
$this->getLayer()->getState()->addFilter($this->_createItem($category->getName(), $id));
}
}
}
if (sizeof($categoryIds)) {
$this->_isFilter = true;
$this->getLayer()->getProductCollection()->addLayerCategoryFilter($categoryIds);
}
if ($parentCategoryId = $request->getParam('id')) {
$this->dataProvider->setCategoryId($parentCategoryId);
}
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,157 @@
<?php
/**
* @category WeltPixel
* @package WeltPixel_LayeredNavigation
* @copyright Copyright (c) 2018 Weltpixel
* @author Weltpixel TEAM
*/
namespace WeltPixel\LayerdNavigation\Model\Layer\Filter;
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
/**
* Class Decimal
* @package WeltPixel\LayerdNavigation\Model\Layer\Filter
*/
class Decimal extends AbstractFilter
{
/**
* @var \Magento\Framework\Pricing\PriceCurrencyInterface
*/
private $priceCurrency;
/**
* @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal
*/
private $resource;
/**
* @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\DecimalFactory $filterDecimalFactory
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @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\DecimalFactory $filterDecimalFactory,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
array $data = []
) {
parent::__construct(
$filterItemFactory,
$storeManager,
$layer,
$itemDataBuilder,
$data
);
$this->resource = $filterDecimalFactory->create();
$this->priceCurrency = $priceCurrency;
}
/**
* Apply price range filter
*
* @param \Magento\Framework\App\RequestInterface $request
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
/**
* Filter must be string: $fromPrice-$toPrice
*/
$filter = $request->getParam($this->getRequestVar());
if (!$filter || is_array($filter)) {
return $this;
}
list($from, $to) = explode('-', $filter);
$this->getLayer()
->getProductCollection()
->addFieldToFilter(
$this->getAttributeModel()->getAttributeCode(),
['from' => $from, 'to' => $to]
);
$this->getLayer()->getState()->addFilter(
$this->_createItem($this->renderRangeLabel(empty($from) ? 0 : $from, $to), $filter)
);
return $this;
}
/**
* Get data array for building attribute filter items
*
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getItemsData()
{
$attribute = $this->getAttributeModel();
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
$productCollection = $this->getLayer()->getProductCollection();
$productSize = $productCollection->getSize();
$facets = $productCollection->getFacetedData($attribute->getAttributeCode());
$data = [];
foreach ($facets as $key => $aggregation) {
$count = $aggregation['count'];
if (!$this->isOptionReducesResults($count, $productSize)) {
continue;
}
list($from, $to) = explode('_', $key);
if ($from == '*') {
$from = '';
}
if ($to == '*') {
$to = '';
}
$label = $this->renderRangeLabel(
empty($from) ? 0 : $from,
empty($to) ? $to : $to
);
$value = $from . '-' . $to;
$data[] = [
'label' => $label,
'value' => $value,
'count' => $count,
'from' => $from,
'to' => $to
];
}
return $data;
}
/**
* Prepare text of range label
*
* @param float|string $fromPrice
* @param float|string $toPrice
* @return \Magento\Framework\Phrase
*/
protected function renderRangeLabel($fromPrice, $toPrice)
{
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
if ($toPrice === '') {
return __('%1 and above', $formattedFromPrice);
} else {
if ($fromPrice != $toPrice) {
$toPrice -= .01;
}
return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice));
}
}
}
@@ -0,0 +1,255 @@
<?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;
/**
* 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;
/**
* @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 \WeltPixel\LayeredNavigation\Helper\Data $moduleHelper
* @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\Tax\Helper\Data $taxHelper,
LayerHelper $moduleHelper,
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;
}
/**
* @inheritdoc
*/
public function apply(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_moduleHelper->isEnabled()) {
return parent::apply($request);
}
/**
* Filter must be string: $fromPrice-$toPrice
*/
$filter = $request->getParam($this->getRequestVar());
if (!$filter || is_array($filter)) {
return $this;
}
$filterParams = explode(',', $filter);
$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 = false);
}
$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));
}
}
/**
* Price Slider Configuration
*
* @return array
*/
public function getSliderConfig()
{
/** @var \WeltPixel\LayeredNavigation\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']);
}
$min = $productCollection->getMinPrice();
$max = $productCollection->getMaxPrice();
list($from, $to) = $this->_filterVal ?: [$min, $max];
$from = ($from < $min) ? $min : $from;
$to = ($to > $max) ? $max : $to;
$item = $this->getItems()[0];
return [
"selectedFrom" => $from,
"selectedTo" => $to,
"minValue" => $min,
"maxValue" => $max,
"priceFormat" => $this->_taxHelper->getPriceFormat(),
"ajaxUrl" => $item->getUrl()
];
}
/**
* 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();
/** @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, $isLast);
}
}
return $data;
}
/**
* @param string $key
* @param int $count
* @param boolean $isLast
* @return array
*/
private function prepareData($key, $count, $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 . $this->dataProvider->getAdditionalRequestData();
$data = [
'label' => $label,
'value' => $value,
'count' => $count,
'from' => $from,
'to' => $to,
];
return $data;
}
}
@@ -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,588 @@
<?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\FilterGroup as SourceFilterGroup;
use Magento\Framework\Api\Search\SearchCriteria;
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) {
$bucketName = $field . RequestGenerator::BUCKET_SUFFIX;
$bucket = $aggregations->getBucket($bucketName);
if ($bucket) {
foreach ($bucket->getValues() as $value) {
$metrics = $value->getMetrics();
$result[$metrics['value']] = $metrics;
}
}
}
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' ) {
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';
}
}

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