Commit 9264db77 authored by Jonathan's avatar Jonathan

re #78 adding fixture processing for configurable products. specify the...

re #78 adding fixture processing for configurable products. specify the relevant attributes by code and child products by id e.g.
    - entity_id: 410955
      attribute_set_id: 4
      type_id: simple
      sku: "Test Simple Child"
      name: "Test Simple Child"
      short_description: "Test Simple Child"
      description: "Test Simple Child"
      url_key: test-child
      website_ids:
        - us
      category_ids:
        - 2 # Default Category
      price: 30.00
      special_price: 30.00
      tax_class_id: 2 # Taxable Goods
      status: 1             # Enabled
      visibility: 4         # Visible in Catalog & Search
      color: 4         # Configurable Super Attribute
    - entity_id: '336835'
      attribute_set_id: 4
      type_id: configurable
      sku: "test-configurable"
      name: "Test Configurable"
      short_description: "Test Configurable"
      description: "Test Configurable"
      url_key: test-configurable
      super_attributes:
        - color
      configurable_children:
        - 410955
      website_ids:
        - us
      category_ids:
        - 2 # Default Category
      price: 30.00
      special_price: 30.00
      tax_class_id: 2 # Taxable Goods
      status: 1             # Enabled
      visibility: 4         # Visible in Catalog & Search
parent 56e875e5
...@@ -59,6 +59,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P ...@@ -59,6 +59,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
$records += $this->_getTierPriceRecords($row, $entityTypeModel); $records += $this->_getTierPriceRecords($row, $entityTypeModel);
$records += $this->_getCategoryAssociationRecords($row, $entityTypeModel); $records += $this->_getCategoryAssociationRecords($row, $entityTypeModel);
$records += $this->_getProductStockRecords($row, $entityTypeModel); $records += $this->_getProductStockRecords($row, $entityTypeModel);
$records += $this->_getProductSuperRelations($row, $entityTypeModel);
return $records; return $records;
} }
...@@ -79,6 +80,50 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P ...@@ -79,6 +80,50 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
return parent::_getAttributeRecords($row, $attribute, $tableColumns); return parent::_getAttributeRecords($row, $attribute, $tableColumns);
} }
/**
* Generates records for catalog_product_super_attribute and catalog_product_super_link tables
*
* @param array $row
* @param Mage_Eav_Model_Entity_Type $entityTypeModel
* @return array
* @throws RuntimeException
*/
protected function _getProductSuperRelations($row, $entityTypeModel)
{
$result = array();
if (isset($row['super_attributes']) && is_array($row['super_attributes'])) {
$records = array();
$attributeCodes = $entityTypeModel->getAttributeCollection();
foreach ($row['super_attributes'] as $attributeCode) {
$attributeId = $attributeCodes->getItemByColumnValue('attribute_code',$attributeCode)->getId();
$records[] = array(
'product_id' => $row[$this->_getEntityIdField($entityTypeModel)],
'attribute_id' => $attributeId
);
}
if ($records) {
$result += array('catalog/product_super_attribute' => $records);
}
}
if (isset($row['configurable_children']) && is_array($row['configurable_children'])) {
$records = array();
foreach ($row['configurable_children'] as $childId) {
$records[] = array(
'parent_id' => $row[$this->_getEntityIdField($entityTypeModel)],
'product_id' => $childId
);
}
if ($records) {
$result += array('catalog/product_super_link' => $records);
}
}
return $result;
}
/** /**
* Generates records for catalog_product_website table * Generates records for catalog_product_website table
* *
......
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