public function testGetLabel() { $this->assertEmpty($this->_model->getLabel()); $this->_model->setProductAttribute(new Varien_Object(array('store_label' => 'Store Label'))); $this->assertEquals('Store Label', $this->_model->getLabel()); $this->_model->setUseDefault(1)->setProductAttribute(new Varien_Object(array('store_label' => 'Other Label'))); $this->assertEquals('Other Label', $this->_model->getLabel()); }
/** * Save Custom labels for Attribute name * * @param Mage_Catalog_Model_Product_Type_Configurable_Attribute $attribute * @return Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute */ public function saveLabel($attribute) { $adapter = $this->_getWriteAdapter(); $select = $adapter->select()->from($this->_labelTable, 'value_id')->where('product_super_attribute_id = :product_super_attribute_id')->where('store_id = :store_id'); $bind = array('product_super_attribute_id' => (int) $attribute->getId(), 'store_id' => (int) $attribute->getStoreId()); $valueId = $adapter->fetchOne($select, $bind); if ($valueId) { $adapter->update($this->_labelTable, array('use_default' => (int) $attribute->getUseDefault(), 'value' => $attribute->getLabel()), $adapter->quoteInto('value_id = ?', (int) $valueId)); } else { $adapter->insert($this->_labelTable, array('product_super_attribute_id' => (int) $attribute->getId(), 'store_id' => (int) $attribute->getStoreId(), 'use_default' => (int) $attribute->getUseDefault(), 'value' => $attribute->getLabel())); } return $this; }