What is SKU
Wikipedia , the smallest inventory unit (keeping), is sometimes called items as a SKU in a chain retail store, defined as the smallest available unit for holding inventory control, such as
For example: the iphone has specifications: Color "red, gold, black", Memory Size "32g, 64g, 128g" Red +32g is a SKU, of course, can also be divided into a more detailed
background data is as follows: (table 1)
Color |
Memory |
Screen Size |
Stock |
Red-A1 |
16g-b1 |
4.7-c1 |
100 |
Golden-A2 |
32g-b2 |
5.1-c2 |
110 |
Black-a3 |
64g-b3 |
4.7 |
120 |
Blue-A4 |
128g-b4 |
4.7 |
130 |
For the above data permutation combination gets, all the inventory SKU
The tabs are: (Table 2)
Color |
Select Item |
|
|
|
Color |
Red |
Golden |
Black |
Blue |
Memory |
16G |
32G |
64G |
128G |
Screen |
4.7 |
5.1 |
|
|
Product Requirements Show optional styles only with inventory buttons
Tab
Store the selected SKU in an array such as: SELECTSKU=[A1,B1,C1]
Programme 1:
Generate a map of all the specification permutations, such as:
skumap={
a1:100,
b1:100,
c1:220,
}
The advantage is that only one operation is required, the latter only need to search through the key, but the initialization of the operation is relatively large
Programme 2:
Each time you choose to recalculate the inventory for the current option, such as:
selectsku=[a1,b1,c1];//has selected the specification
//If you want to know if C2 can choose, you need to obtain the inventory
/other analogy of KEY=A1B1C2 this SKU
Here thank you very much for a piece of article, write a very carefully. Interested can refer to the
Http://git.shepherdwind.com/sku-search-algorithm.html