Answer the question
In order to leave comments, you need to log in
What algorithm to use for a product with parameters?
There is a product.
It has parameters, for example:
- Color (red, green blue)
- Material (cotton, silk)
- Size (xs, s, m, l)
There can be any number of these parameters, as well as the values of the parameters themselves.
The combination of values for the parameters (3 parameters in the example) gives some unique variation of the product with its id, price. Parameter values can be combined in different ways. Those. there may not be an xs size for blue. The number of all possible product variations is not equal to the product of all the number of parameter values.
The data is stored as a multidimensional array, something like this:
$arr = array(
0 => array(
'variation_id' => 100,
'price' => 1000,
'parameters' => array(
'color' => 'red',
'material' => 'cotton',
'size' => 'xs'
)
),
1 => array(
'variation_id' => 101,
'price' => 1001,
'parameters' => array(
'color' => 'green',
'material' => 'cotton',
'size' => 'xs'
)
),
2 => array(
'variation_id' => 102,
'price' => 1002,
'parameters' => array(
'color' => 'red',
'material' => 'cotton',
'size' => 's'
)
),
...
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question