diff --git a/install-dev/fixtures/fashion/data/generate_attribute.php b/install-dev/fixtures/fashion/data/generate_attribute.php new file mode 100644 index 000000000..2e002a59f --- /dev/null +++ b/install-dev/fixtures/fashion/data/generate_attribute.php @@ -0,0 +1,53 @@ + array( + 'Color' => array('Grey'), + 'Size' => array('S', 'M', 'L') + ) +); + +$content_product_attribute = ''; +$content_product_attribute_combination = ''; + +foreach ($products as $product => $attribute_groups) +{ + $default_on = 1; + $pa_id = 1; + $combinations = createCombinations($attribute_groups); + + $pa_id = 1; + $pac_id = 1; + foreach ($combinations as $attributes) + { + foreach ($attributes as $attribute_value) + { + $content_product_attribute_combination .= ''."\n"; + ++$pac_id; + } + $content_product_attribute .= ''."\n"; + $default_on = 0; + + ++$pa_id; + } +} + +echo "This is an XML file, look at the source!\n\n"; +echo $content_product_attribute; +echo "\n\n"; +echo $content_product_attribute_combination; + +function createCombinations($list) +{ + if (count($list) <= 1) + return count($list) ? array_map(create_function('$v', 'return (array($v));'), array_shift($list)) : $list; + $res = array(); + $first = array_pop($list); + foreach ($first as $attribute) + { + $tab = createCombinations($list); + foreach ($tab as $to_add) + $res[] = is_array($to_add) ? array_merge($to_add, array($attribute)) : array($to_add, $attribute); + } + return $res; +} \ No newline at end of file diff --git a/install-dev/fixtures/fashion/data/product_attribute.xml b/install-dev/fixtures/fashion/data/product_attribute.xml index a6fc0763e..be67991f9 100644 --- a/install-dev/fixtures/fashion/data/product_attribute.xml +++ b/install-dev/fixtures/fashion/data/product_attribute.xml @@ -18,86 +18,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/install-dev/fixtures/fashion/data/product_attribute_combination.xml b/install-dev/fixtures/fashion/data/product_attribute_combination.xml index 3c6f67ff2..d248b609a 100644 --- a/install-dev/fixtures/fashion/data/product_attribute_combination.xml +++ b/install-dev/fixtures/fashion/data/product_attribute_combination.xml @@ -4,57 +4,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +