33 \Magento\Framework\DataObject\IdentityInterface
87 private $swatchAttributesProvider;
92 private $imageUrlBuilder;
127 $this->swatchAttributesProvider = $swatchAttributesProvider
151 return parent::getCacheKey() .
'-' . $this->
getProduct()->getId();
162 return parent::hasCacheLifetime() ? parent::getCacheLifetime() : 3600;
174 $swatchesData = $this->swatchHelper->getSwatchesByOptionsId($allOptionIds);
178 if (isset($attributeDataArray[
'options'])) {
180 $attributeDataArray[
'options'],
187 return $this->jsonEncoder->encode(
$config);
198 return $this->_scopeConfig->getValue(
199 'catalog/frontend/swatches_per_product',
223 if (!$this->product) {
224 $this->product = parent::getProduct();
235 return $this->swatchHelper->getSwatchAttributesAsArray($this->
getProduct());
257 $swatchAttributes = $this->swatchAttributesProvider->provide($this->
getProduct());
258 return count($swatchAttributes) > 0;
271 array $swatchesCollectionArray,
272 array $attributeDataArray
276 if (isset($swatchesCollectionArray[
$optionId])) {
296 if (isset($attributeDataArray[
'use_product_image_for_swatch'])
297 && $attributeDataArray[
'use_product_image_for_swatch']
300 if (! empty($variationMedia)) {
302 $swatch = array_merge($swatch, $variationMedia);
316 $result[
'type'] = $swatchDataArray[
'type'];
319 $result[
'value'] = $this->swatchMediaHelper->getSwatchAttributeImage(
321 $swatchDataArray[
'value']
323 $result[
'thumb'] = $this->swatchMediaHelper->getSwatchAttributeImage(
325 $swatchDataArray[
'value']
328 $result[
'value'] = $swatchDataArray[
'value'];
343 $variationProduct = $this->swatchHelper->loadFirstVariationWithSwatchImage(
348 if (!$variationProduct) {
349 $variationProduct = $this->swatchHelper->loadFirstVariationWithImage(
355 $variationMediaArray = [];
356 if ($variationProduct) {
357 $variationMediaArray = [
363 return $variationMediaArray;
374 $swatchImageId = $imageType;
378 $imageAttributes = [
'type' =>
'image'];
381 if (!empty($swatchImageId) && !empty($imageAttributes[
'type'])) {
382 return $this->imageUrlBuilder->getUrl(
$childProduct->getData($imageAttributes[
'type']), $swatchImageId);
393 return $product->getData($imageType) !==
null &&
$product->getData($imageType) != SwatchData::EMPTY_IMAGE_VALUE;
401 protected function getConfigurableOptionsIds(array
$attributeData)
406 foreach ($this->helper->getAllowAttributes($this->getProduct()) as
$attribute) {
407 $productAttribute =
$attribute->getProductAttribute();
408 $productAttributeId = $productAttribute->getId();
410 $ids[
$product->getData($productAttribute->getAttributeCode())] = 1;
414 return array_keys($ids);
429 return parent::toHtml();
461 return parent::_toHtml();
469 return $this->
getUrl(self::MEDIA_CALLBACK_ACTION, [
'_secure' => $this->
getRequest()->isSecure()]);
481 return $this->product->getIdentities();
494 $imageConfig = $this->swatchMediaHelper->getImageConfig();
502 return $this->jsonEncoder->encode($sizeConfig);
$configurableAttributeData
const SWATCH_RENDERER_TEMPLATE
const MEDIA_CALLBACK_ACTION
getNumberSwatchesPerProduct()
getSwatchProductImage(Product $childProduct, $imageType)
elseif(isset( $params[ 'redirect_parent']))
isProductHasSwatchAttribute()
initIsProductHasSwatchAttribute()
const SWATCH_THUMBNAIL_NAME
setProduct(Product $product)
const SWATCH_TYPE_VISUAL_IMAGE
const CONFIGURABLE_RENDERER_TEMPLATE
$isProductHasSwatchAttribute
__construct(Context $context, ArrayUtils $arrayUtils, EncoderInterface $jsonEncoder, Data $helper, CatalogProduct $catalogProduct, CurrentCustomer $currentCustomer, PriceCurrencyInterface $priceCurrency, ConfigurableAttributeData $configurableAttributeData, SwatchData $swatchHelper, Media $swatchMediaHelper, array $data=[], SwatchAttributesProvider $swatchAttributesProvider=null, UrlBuilder $imageUrlBuilder=null)
getUrl($route='', $params=[])
const SWATCH_THUMBNAIL_NAME
getSwatchAttributesData()
getVariationMedia($attributeCode, $optionId)
addAdditionalMediaData(array $swatch, $optionId, array $attributeDataArray)
addSwatchDataForAttribute(array $options, array $swatchesCollectionArray, array $attributeDataArray)
extractNecessarySwatchData(array $swatchDataArray)
isProductHasImage(Product $product, $imageType)
getJsonSwatchSizeConfig()