I've installed also the dynamic_drop_downs_for_stock_by_attributes, and the situation is changed, so that now I can give some suggestions.
Consider a dress named 'Anais' with two or more ORDERED attribuTES, for example
first -> the size
second -> the color
and that we have values for that attributes created via admin.
To buid an external program for modifying the quantities we can:
- From the TABLE
products_description create an array
with all the products_id and products_name of the products.
With the products_id we'll make a foreach to examine all the
products (in english -> second field=1)
(9,1, 'Anais', '', '', 55),
products_id = 9
products_name = Anais
- From TABLE
products_attributes create an hash (**)
containing the values of products_attributes_id,
options_id and options_values_id related to the
current products_id.
(15, 9, 1, 15, ....
(14, 9, 1, 8, ....
(9, 9, 2, 32, ....
(10, 9, 2, 33, ....
(11, 9, 2, 34, ....
(12, 9, 2, 35, ....
(13, 9, 1, 3, ....
(16, 9, 1, 27, ....
products_id=9 , options_id=1, options_values_id=15
products_id=9 , options_id=1, options_values_id=8
products_id=9 , options_id=2, options_values_id=32
products_id=9 , options_id=2, options_values_id=33
products_id=9 , options_id=2, options_values_id=34
products_id=9 , options_id=2, options_values_id=35
products_id=9 , options_id=1, options_values_id=3
products_id=9 , options_id=1, options_values_id=27
- From TABLE
products_with_attributes_stock create an
hash containing for all the products_id the values of
stock_attributes e quantity.
(11, 9, '10,15', 14),
(10, 9, '9,16', 13),
(9, 9, '9,15', 12),
(8, 9, '11,14', 11),
(12, 9, '12,15', 15),
(13, 9, '10,13', 16),
(14, 9, '12,16', 0);
products_id=9, stock_attributes='10,15', quantity=14
products_id=9, stock_attributes='9,16' , quantity=13
products_id=9, stock_attributes='9,15' , quantity=12
products_id=9, stock_attributes='11,14', quantity=11
products_id=9, stock_attributes='12,15', quantity=15
products_id=9, stock_attributes='10,13', quantity=16
products_id=9, stock_attributes='12,16', quantity=0
- For each element of the hash, by an 'explode'
separate the two numbers of the stock_attributes,
remembering that the first number is related to the
size (products_options_id = 1), the second to the color,
(products_options_id = 2) and so on.
'10,15' -> 10==Size 15==Color
- With the first number point to the hash (**) ed estract
the value of options_values_id.
(10, 9, 2, 33, ....
products_id=9 , options_id=2, options_values_id=33
- With the value of
options_values_id estract from
TABLE products_options_values the descrition of the
size, (in english -> second field=1)
.....................
(32, 2, 'Taglia 40', 20),
(32, 1, 'Size 40', 20),
(33, 2, 'Taglia 42', 30),
(33, 1, 'Size 42', 30), <--------
(34, 2, 'Taglia 44', 40),
(34, 1, 'Size 44', 40),
.....................
- Make tha same thing with the secon number obtaining the
description of the color.
(15, 9, 1, 15, ....
products_id=9 , options_id=1, options_values_id=15
.....................
(14, 2, 'Moro', 140),
(14, 1, 'Dark', 140),
(15, 2, 'Nero', 150),
(15, 1, 'Black', 150), <--------
(16, 2, 'Nero e bianco', 160),
(16, 1, 'Black and white', 160),
.....................
-
Now we have all the data to show the product on the screen
for modifying the value of 'quantity'.
-
Continue for all the element of the hash related
to the TABLE products_with_attributes_stock and then
continue with the next products_id of the foreach.
Giovanni