/** * Return translated category name * * :KLUDGE: it's the hack to prevent execution of superflous queries * * @param array $category Category data * * @return string */ protected function getCategoryName(array $category) { $name = null; $query = \XLite\Core\Translation::getLanguageQuery(\XLite\Core\Session::getInstance()->getLanguage()->getCode()); foreach ($query as $code) { $data = \Includes\Utils\ArrayManager::searchInArraysArray($category['translations'], 'code', $code); if (!empty($data)) { $name = $data['name']; break; } } return $name; }
/** * Get attribute column data * * @param \XLite\Model\Product $product Product object * @param \XLite\Model\Attribute $attribute Attribute object * * @return array */ protected function getAttributeValue($product, $attributeName) { $value = null; $attr = \Includes\Utils\ArrayManager::searchInArraysArray($this->getAttributesColumns(), 'attributeName', $attributeName); if ($attr) { $entity = \XLite\Core\Database::getRepo('XLite\\Model\\Attribute')->find($attr['attributeId']); if ($entity) { $value = $entity->getAttributeValue($product, true); } if ($value && is_array($value)) { $value = array_shift($value); } } return $value ?: ''; }
/** * Return translated category name * * :KLUDGE: it's the hack to prevent execution of superflous queries * * @param array $category Category data * * @return string */ protected function getCategoryName(array $category) { $data = \Includes\Utils\ArrayManager::searchInArraysArray($category['translations'], 'code', \XLite\Core\Session::getInstance()->getLanguage()->getCode()); return empty($data) ? null : $data['name']; }