![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Cnc/SeoXTemplates/Preference/Model/Converter/Product/ |
<?php /** * Copyright (c) 2021 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * Krzysztof Majkowski <[email protected]> */ namespace Cnc\SeoXTemplates\Preference\Model\Converter\Product; class MetaDescription extends \MageWorx\SeoXTemplates\Model\Converter\Product\MetaDescription { /** * @overridden * @return mixed|string */ protected function _convertCategories() { $categoryId = $this->_getCategoryId(); if (!$categoryId) { return ''; } return parent::_convertCategories(); } /** * @overridden * * Overridden due to limit description to 70 chars' * * @param string $attributeCode * @return false|mixed|string|null */ protected function _convertAttribute($attributeCode) { $tempValue = ''; $value = $this->item->getData($attributeCode); if ($attributeCode == 'description') { $value = trim(substr(str_replace(' ', ' ', strip_tags($value)), 0, 73)); } if ($_attr = $this->item->getResource()->getAttribute($attributeCode)) { $_attr->setStoreId($this->item->getStoreId()); if ($_attr->usesSource()) { $tempValue = $_attr->setStoreId($this->item->getStoreId())->getSource()->getOptionText( $this->item->getData($attributeCode) ); } } if ($tempValue) { $value = $tempValue; } if (!$value) { if ($this->item->getTypeId() == 'configurable') { $productAttributeOptions = $this->item->getTypeInstance(true)->getConfigurableAttributesAsArray( $this->item ); $attributeOptions = []; foreach ($productAttributeOptions as $productAttribute) { if ($productAttribute['attribute_code'] == $attributeCode) { foreach ($productAttribute['values'] as $attribute) { $attributeOptions[] = $attribute['store_label']; } } } if (count($attributeOptions) == 1) { $value = array_shift($attributeOptions); } } else { $value = $this->item->getData($attributeCode); } } return is_array($value) ? implode(', ', $value) : $value; } }