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,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();
}
}