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