コード例 #1
0
 /**
  * prepare attribute groups
  *
  * @return array
  */
 protected function prepareAttributeGroups()
 {
     $result = array();
     if ($this->currentProduct->hasAttributes()) {
         //function getAttributesInformationsByProduct available from version 1.5.0.1
         if (version_compare(_PS_VERSION_, '1.5.0.1', '<')) {
             $attributes = BWProduct::getAttributesInformationsByProduct($this->currentProduct->id, $this->getPlugin()->getLanguageId());
         } else {
             $attributes = Product::getAttributesInformationsByProduct($this->currentProduct->id);
         }
         $addedGroup = array();
         foreach ($attributes as $attribute) {
             if (!in_array($attribute['id_attribute_group'], $addedGroup)) {
                 $attributeItem = new Shopgate_Model_Catalog_AttributeGroup();
                 $attributeItem->setUid($attribute['id_attribute_group']);
                 $attributeItem->setLabel($attribute['group']);
                 $result[] = $attributeItem;
                 $addedGroup[] = $attribute['id_attribute_group'];
             }
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: Xml.php プロジェクト: buttasg/cowgirlk
 /**
  * set attribute groups
  */
 public function setAttributeGroups()
 {
     if ($this->item->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $productTypeInstance = $this->item->getTypeInstance(true);
         if ($productTypeInstance == null || !method_exists($productTypeInstance, "getUsedProducts")) {
             return;
         }
         $configurableAttributes = $productTypeInstance->getConfigurableAttributes($this->item);
         $result = array();
         foreach ($configurableAttributes as $attribute) {
             /* @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */
             $attributeItem = new Shopgate_Model_Catalog_AttributeGroup();
             $attributeItem->setUid($attribute->getAttributeId());
             $attributeItem->setLabel($attribute->getProductAttribute()->getStoreLabel());
             $result[] = $attributeItem;
         }
         parent::setAttributeGroups($result);
     }
 }