/** * Retrieve product type attributes * * @return array */ public function getEditableAttributes() { if (is_null($this->_editableAttributes)) { $this->_editableAttributes = parent::getEditableAttributes(); foreach ($this->_editableAttributes as $index => $attribute) { if ($this->getUsedProductAttributeIds() && in_array($attribute->getAttributeId(), $this->getUsedProductAttributeIds())) { unset($this->_editableAttributes[$index]); } } } return $this->_editableAttributes; }
/** * @magentoDataFixture Mage/Catalog/_files/product_simple.php */ public function testGetEditableAttributes() { $product = new Mage_Catalog_Model_Product(); $product->load(1); // fixture $this->assertArrayNotHasKey('_cache_editable_attributes', $product->getData()); $attributes = $this->_model->getEditableAttributes($product); $this->assertArrayHasKey('_cache_editable_attributes', $product->getData()); // not clear how to test what is apply_to and what does it have to do with "editable" term foreach ($attributes as $attribute) { $this->assertInstanceOf('Mage_Catalog_Model_Resource_Eav_Attribute', $attribute); } }
/** * @magentoDataFixture Mage/Catalog/_files/product_simple.php */ public function testGetEditableAttributes() { $product = Mage::getModel('Mage_Catalog_Model_Product'); $product->load(1); // fixture $this->assertArrayNotHasKey('_cache_editable_attributes', $product->getData()); $attributes = $this->_model->getEditableAttributes($product); $this->assertArrayHasKey('_cache_editable_attributes', $product->getData()); // not clear how to test what is apply_to and what does it have to do with "editable" term $isTypeExists = false; foreach ($attributes as $attribute) { $this->assertInstanceOf('Mage_Catalog_Model_Resource_Eav_Attribute', $attribute); $applyTo = $attribute->getApplyTo(); if (count($applyTo) > 0 && !in_array('simple', $applyTo)) { $isTypeExists = true; } } $this->assertTrue($isTypeExists); }