2015-08-28 24 views
0

基本上我運行了一個Magento商店,有各種服裝產品。我需要以某種方式使用excel,以便我可以輸入我的產品名稱,SKU和屬性,以生成Magento csv導入文件。我如何在excel中爲我的產品屬性進行分類magento導入

我有很多的屬性,如顏色,腳尺寸,腰圍尺寸。

例如,一種產品可以具有以下潛在的屬性

貨物長褲 -

顏色:黑色,海軍,卡其

腿尺寸:31,33,35

腰圍:32,34,36,38,40,42

我需要以某種方式設置一個循環,可以採取的值和安排他們在以下格式

顏色| LegSize |腰|

黑色| 31 | 34 |

黑色| 31 | 36 |

黑色| 31 | 38 |

我希望我說清楚。例如,該產品將有超過54種變化。

我從字面上想要能夠輸入變化,並有卓越的努力工作。

回答

0

怎麼樣遞歸函數調用,而不是循環?

這裏是我的結構我的數據來回答你的問題(我還沒有足夠的代表處發佈的圖片,所以這裏是我使用的表的示意圖:

 
+---------------------------------------+ 
| |  A  | B  | C | 
|---------------------------------------| 
| 1 | Cargo Trousers |   |  | 
|---------------------------------------| 
| 2 | Colours  | Leg Size | Waist | 
|---------------------------------------| 
| 3 | Black   | 31  | 32 | 
|---------------------------------------| 
| 4 | Navy   | 33  | 34 | 
|---------------------------------------| 
| 5 | Khaki   | 35  | 36 | 
|---------------------------------------| 
| 6 |    |   | 38 | 
|---------------------------------------| 
| 7 |    |   | 40 | 
|---------------------------------------| 
| 8 |    |   | 42 | 
+---------------------------------------+ 

下面是一大塊代碼,你可以用它來獲得你想要的列表,請注意它正在尋找空單元格,所以不要跳過:)

Option Explicit 

Dim HomeSheet As String 
Dim NewSheet As String 

Function GetAllPermutations() 

    HomeSheet = ActiveSheet.Name 'Where we start from 
    NewSheet = Sheets.Add.Name 'Place to put new stuff 
    Sheets(HomeSheet).Select 

    RecursivePermutations "", 1, 0 

End Function 

Function RecursivePermutations(ByVal CurrentValue As String, ByVal SourceColumn As Long, ByRef OutputRow As Long) 

    Dim x As Long 
    Dim myText As String 

    For x = 3 To Cells.Rows.Count 

     'Is this row's value empty? Then we need to exit 
     If Cells(x, SourceColumn) = "" Then 
      If x = 3 Then 
       'We hit a brand new blank column, time to write it out 
       OutputRow = OutputRow + 1 
       Sheets(NewSheet).Cells(OutputRow, 1) = CurrentValue 
      End If 
      'All done here 
      Exit Function 
     End If 

     If SourceColumn = 1 Then 
      'First time through loop for this base value 
      myText = Trim(Cells(x, SourceColumn)) 
     Else 
      'Add another one 
      myText = "|" & Trim(Cells(x, SourceColumn)) 
     End If 

     'Make recursive call to self 
     RecursivePermutations CurrentValue & myText, SourceColumn + 1, OutputRow 

    Next x 

End Function 
相關問題