/** * @param ProductCore $product * @param $attributeId * @return bool */ protected function _validateProduct(ProductCore $product, $attributeId) { if (Validate::isLoadedObject($product)) { if ($attributeId) { if (version_compare(_PS_VERSION_, '1.5.0', '<')) { $attributeIds = BWProduct::getProductAttributesIds($product->id); } else { $attributeIds = $product->getProductAttributesIds($product->id, true); } foreach ($attributeIds as $id) { if ($id['id_product_attribute'] == $attributeId) { return true; } } return false; } return true; } return false; }
/** * 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; }