5
* @author Sharoon Thomas
6
* Inspired from Dieter's Magento Extender
10
class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource {
11
public function items($setId = null)
13
$groups = Mage::getModel('eav/entity_attribute_group')->getResourceCollection();
15
if(!is_null($setId) && !empty($setId) && is_numeric($setId))
17
$groups->setAttributeSetFilter($setId);
24
foreach($groups as $group)
27
'attribute_group_id' => $group->getAttributeGroupId(),
28
'attribute_set_id' => $group->getAttributeSetId(),
29
'attribute_group_name' => $group->getAttributeGroupName(),
30
'sort_order' => $group->getSortOrder(),
31
'default_id' => $group->getDefaultId()
39
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
40
<param><value><string>catalog_product_attribute_group.create</string></value></param>
45
<value><i4>26</i4></value>
46
<value><string>Leonelle</string></value>
52
public function create($setId, array $data)
56
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
57
$attrOption = Mage::getModel("eav/entity_attribute_group");
59
$attrOption->addData($data);
61
// check if there already exists a group with the give groupname
62
if($attrOption->itemExists())
64
$this->_fault("group_already_exists");
69
return (int)$attrOption->getAttributeGroupId();
77
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
78
<param><value><string>catalog_product_attribute_group.update</string></value></param>
83
<value><i4>85</i4></value>
84
<value><string>Leonelle2</string></value>
85
<value><i4>85</i4></value>
86
<value><i4>85</i4></value>
92
public function update(array $data)
96
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
97
$attrOption = Mage::getModel("eav/entity_attribute_group");
99
$attrOption->load($data["attribute_group_id"]);
101
// check if the requested group exists...
102
if(!$attrOption->getAttributeGroupId())
104
$this->_fault("group_not_exists");
107
$attrOption->addData($data);
120
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
121
<param><value><string>catalog_product_attribute_group.delete</string></value></param>
126
<value><i4>85</i4></value>
132
public function delete($groupId)
136
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
137
$attrOption = Mage::getModel("eav/entity_attribute_group");
139
$attrOption->load($groupId);
141
// check if the requested group exists...
142
if(!$attrOption->getAttributeGroupId())
144
$this->_fault("group_not_exists");
148
$attrOption->delete();