/** * Set current attribute to entry (for specified product) * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Framework\Gdata\Gshopping\Entry $entry * @return \Magento\Framework\Gdata\Gshopping\Entry */ public function convertAttribute($product, $entry) { $targetCountry = $this->_config->getTargetCountry($product->getStoreId()); $value = $this->_typeFactory->create()->loadByAttributeSetId($product->getAttributeSetId(), $targetCountry); $val = $value->getCategory() == \Magento\GoogleShopping\Helper\Category::CATEGORY_OTHER ? '' : $value->getCategory(); $this->_setAttribute($entry, 'google_product_category', self::ATTRIBUTE_TYPE_TEXT, htmlspecialchars_decode($val, ENT_NOQUOTES)); return $entry; }
/** * Return Google Content Item Type Model for current Item * * @return \Magento\GoogleShopping\Model\Type */ public function getType() { $attributeSetId = $this->getProduct()->getAttributeSetId(); $targetCountry = $this->getTargetCountry(); $registry = $this->_registry->registry(self::TYPES_REGISTRY_KEY); if (is_array($registry) && isset($registry[$attributeSetId][$targetCountry])) { return $registry[$attributeSetId][$targetCountry]; } $type = $this->_typeFactory->create()->loadByAttributeSetId($attributeSetId, $targetCountry); $registry[$attributeSetId][$targetCountry] = $type; $this->_registry->unregister(self::TYPES_REGISTRY_KEY); $this->_registry->register(self::TYPES_REGISTRY_KEY, $registry); return $type; }