Commit ec26f037 authored by Jonathan Day's avatar Jonathan Day

working code to import Attribute fixture data. Also tests for existence of...

working code to import Attribute fixture data. Also tests for existence of attribute in Configurable product Fixture loader
parent 4ea1194a
...@@ -89,11 +89,12 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract ...@@ -89,11 +89,12 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
} }
else { else {
$aAttributeCodes = array(); $aAttributeCodes = array();
foreach($attributes as $oAttribute){ foreach($attributes[$entityType] as $aAttribute){
$aAttributeCodes[] = $oAttribute->getCode(); $aAttributeCodes[] = $aAttribute['attribute_code'];
} }
} }
//delete entry from eav/attribute and allow FK cascade to delete all related values //delete entry from eav/attribute and allow FK cascade to delete all related values
//TODO: check if the attribute != is_user_defined (ie system), then *only* delete the attribute option values, not attribute definition
$this->_getWriteAdapter() $this->_getWriteAdapter()
->delete( ->delete(
$this->getTable('eav/attribute'), $this->getTable('eav/attribute'),
......
...@@ -95,7 +95,11 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P ...@@ -95,7 +95,11 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
$records = array(); $records = array();
$attributeCodes = $entityTypeModel->getAttributeCollection(); $attributeCodes = $entityTypeModel->getAttributeCollection();
foreach ($row['super_attributes'] as $attributeCode) { foreach ($row['super_attributes'] as $attributeCode) {
$attributeId = $attributeCodes->getItemByColumnValue('attribute_code',$attributeCode)->getId(); $oAttribute = $attributeCodes->getItemByColumnValue('attribute_code', $attributeCode);
if(!$oAttribute){
throw new Exception('Super attribute not found with code: ' . $attributeCode);
}
$attributeId = $oAttribute->getId();
$records[] = array( $records[] = array(
'product_id' => $row[$this->_getEntityIdField($entityTypeModel)], 'product_id' => $row[$this->_getEntityIdField($entityTypeModel)],
'attribute_id' => $attributeId 'attribute_id' => $attributeId
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment