9 use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory;
32 protected $_template =
'Magento_Swatches::product/layered/renderer.phtml';
80 parent::__construct($context,
$data);
91 $this->eavAttribute =
$filter->getAttributeModel();
101 if (
false === $this->eavAttribute instanceof
Attribute) {
102 throw new \RuntimeException(
'Magento_Swatches: RenderLayered: Attribute has not been set.');
105 $attributeOptions = [];
106 foreach ($this->eavAttribute->getOptions() as
$option) {
108 $attributeOptions[
$option->getValue()] = $currentOption;
114 $attributeOptionIds = array_keys($attributeOptions);
115 $swatches = $this->swatchHelper->getSwatchesByOptionsId($attributeOptionIds);
118 'attribute_id' => $this->eavAttribute->getId(),
119 'attribute_code' => $this->eavAttribute->getAttributeCode(),
120 'attribute_label' => $this->eavAttribute->getStoreLabel(),
121 'options' => $attributeOptions,
122 'swatches' => $swatches,
136 return $this->_urlBuilder->getUrl(
'*/*/*', [
'_current' =>
true,
'_use_rewrite' =>
true,
'_query' =>
$query]);
146 'label' => $swatchOption->
getLabel(),
147 'link' =>
'javascript:void();',
148 'custom_style' =>
'disabled' 159 $resultOption =
false;
165 return $resultOption;
176 $linkToOption = $this->
buildUrl($this->eavAttribute->getAttributeCode(), $filterItem->getValue());
178 $customStyle =
'disabled';
179 $linkToOption =
'javascript:void();';
183 'label' => $swatchOption->
getLabel(),
184 'link' => $linkToOption,
185 'custom_style' => $customStyle
212 return !$filterItem->getCount();
222 foreach ($filterItems as
$item) {
237 $imagePath = $this->mediaHelper->getSwatchAttributeImage(
$type, $filename);
const FILTERABLE_WITH_RESULTS
__construct(\Magento\Framework\View\Element\Template\Context $context, Attribute $eavAttribute, AttributeFactory $layerAttribute, \Magento\Swatches\Helper\Data $swatchHelper, \Magento\Swatches\Helper\Media $mediaHelper, array $data=[])
getOptionViewData(FilterItem $filterItem, Option $swatchOption)
elseif(isset( $params[ 'redirect_parent']))
getSwatchPath($type, $filename)
getFilterItemById(array $filterItems, $id)
isOptionVisible(FilterItem $filterItem)
isOptionDisabled(FilterItem $filterItem)
buildUrl($attributeCode, $optionId)
getUnusedOption(Option $swatchOption)
setSwatchFilter(\Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter)
getFilterOption(array $filterItems, Option $swatchOption)