/** * @dataProvider prepareAttributesWithDefaultValueForSaveDataProvider */ public function testPrepareAttributesWithDefaultValueForSave($rowData, $withDefaultValue, $expectedAttributes) { $actualAttributes = $this->_model->prepareAttributesWithDefaultValueForSave($rowData, $withDefaultValue); foreach ($expectedAttributes as $key => $value) { $this->assertArrayHasKey($key, $actualAttributes); $this->assertEquals($value, $actualAttributes[$key]); } }
/** * Adds bundle price type to internal attributes. * * @return Danslo_ApiImport_Model_Import_Entity_Product_Type_Bundle */ public function _initAttributes() { parent::_initAttributes(); // Price type does not live in an attribute set, so it is not picked up by abstract _initAttributes method. We add it here manually. $attribute = Mage::getResourceModel('catalog/eav_attribute')->load('price_type', 'attribute_code'); foreach (array_keys($this->_attributes) as $attrSetName) { $this->_addAttributeParams($attrSetName, array('id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'for_configurable' => $attribute->getIsConfigurable(), 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'is_unique' => $attribute->getIsUnique(), 'frontend_label' => $attribute->getFrontendLabel(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes))); } return $this; }
/** * Add attribute parameters to appropriate attribute set. * * @param string $attrParams Name of attribute set. * @param array $attrParams Refined attribute parameters. * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract */ protected function _addAttributeParams($attrSetName, array $attrParams) { // save super attributes for simplier and quicker search in future if ('select' == $attrParams['type'] && 1 == $attrParams['is_global'] && $attrParams['for_configurable']) { $this->_superAttributes[$attrParams['code']] = $attrParams; } return parent::_addAttributeParams($attrSetName, $attrParams); }