Example #1
0
 /**
  * Return Product Attribute Store Label
  * Set attribute name like frontend lable for custom attributes (which wasn't defined by Google)
  *
  * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
  * @param int $storeId Store View Id
  * @return string Attribute Store View Label or Attribute code
  */
 public function getAttributeLabel($attribute, $storeId)
 {
     $attributeId = $attribute->getId();
     $frontendLabel = $attribute->getFrontend()->getLabel();
     if (is_array($frontendLabel)) {
         $frontendLabel = array_shift($frontendLabel);
     }
     if (!isset($this->_attributeLabels[$attributeId])) {
         $this->_attributeLabels[$attributeId] = $attribute->getStoreLabels();
     }
     if (isset($this->_attributeLabels[$attributeId][$storeId])) {
         return $this->_attributeLabels[$attributeId][$storeId];
     } elseif (!empty($frontendLabel)) {
         return $frontendLabel;
     } else {
         return $attribute->getAttributeCode();
     }
 }