- Posts: 109
Import Bundle Items
- JD Cox
- Topic Author
- Offline
- User
Less
More
8 years 2 weeks ago #2959
by JD Cox
Import Bundle Items - Post(2959) was created by JD Cox
We have a customer that’s planning to offer bundled items on the site over the holidays. They did this last year but manually added the list of items to the import file.
I would like them to leave the bundle item on the file and let us (FH) remove/replace the bundle item and add the list of items from a SS we’ll maintain.
Order item qty
100 X101 2
100 X200 1
100 B101 2
During the import is it possible to replace the B101 (bundle item) identified by the ‘B’ with the list below
Bundle List:
BSKU SKU QTY
B101 X300 1
B101 X400 2
B101 X500 3
SO, after the import the order will look like this.
Order item qty
100 X101 2
100 X200 1
100 X300 2
100 X400 4
100 X500 6
I can replace the one SKU no problem I just can not continue through the list.
Thanks for your continued support, JD
I would like them to leave the bundle item on the file and let us (FH) remove/replace the bundle item and add the list of items from a SS we’ll maintain.
Order item qty
100 X101 2
100 X200 1
100 B101 2
During the import is it possible to replace the B101 (bundle item) identified by the ‘B’ with the list below
Bundle List:
BSKU SKU QTY
B101 X300 1
B101 X400 2
B101 X500 3
SO, after the import the order will look like this.
Order item qty
100 X101 2
100 X200 1
100 X300 2
100 X400 4
100 X500 6
I can replace the one SKU no problem I just can not continue through the list.
Thanks for your continued support, JD
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
8 years 2 weeks ago - 8 years 2 weeks ago #2961
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Import Bundle Items - Post(2961)
Hi JD,
It would be posible but it´s a bit tricky
First you have to prepare a CSV file with all available bundle articles. For each bundle article you need one line.
The first column is the bundle article number and the second column ist the count how many articles the bundle article contains. The next colums are the containing article numbers followed by the quantity and so on.
For example:
item,count,artnr1,qty1,artnr2,qty2,artnr3,qty2,...
B101,3,X300,1,X400,2,X500,3,...
To extent the current read text file for the containing bundle articles you need the GroupOut Heater . With this you just make as many line copies you need for the bundle article. The count are read with the help of the String Replace Heater from the bundle article CSV file .
Now you need a little script (see below) and the help if the .NET Script Heater to get dynamically the bundle article and the quantity or in case no bundle article the original values from the READ side.
Sounds quit strange but I guess you are able to understand the attached example I’ve made for you.
Important: Please take care about the input parameter sequence!
C# .Net Script to extend the bundle articles
It would be posible but it´s a bit tricky
First you have to prepare a CSV file with all available bundle articles. For each bundle article you need one line.
The first column is the bundle article number and the second column ist the count how many articles the bundle article contains. The next colums are the containing article numbers followed by the quantity and so on.
For example:
item,count,artnr1,qty1,artnr2,qty2,artnr3,qty2,...
B101,3,X300,1,X400,2,X500,3,...
To extent the current read text file for the containing bundle articles you need the GroupOut Heater . With this you just make as many line copies you need for the bundle article. The count are read with the help of the String Replace Heater from the bundle article CSV file .
Now you need a little script (see below) and the help if the .NET Script Heater to get dynamically the bundle article and the quantity or in case no bundle article the original values from the READ side.
Sounds quit strange but I guess you are able to understand the attached example I’ve made for you.
Important: Please take care about the input parameter sequence!
C# .Net Script to extend the bundle articles
Code:
// you may change here the bundle file name and the delimiter
string bundlefile = "bundles.txt";
char [] delimiter = { ',' };
public object DoWork()
{
if (InValues.Length < 2)
throw new Exception("min. 2 input parameter expected!");
// read all lines from the bundle file
string [] lines = File.ReadAllLines(bundlefile);
// get current group out position (AutoID Heater)
int pos = (int)InValues[0].GetInt();
// get current item
string item = (string)InValues[1].GetString();
// in case a third parameter is valid get the quantity
int qty = -1;
if (InValues.Length > 2)
qty = (int)InValues[2].GetInt();
// loop over all lines an search for a bundle article
foreach (string line in lines)
{
// split the line and compare the item number
string [] columns = line.Split(delimiter);
if (item.CompareTo(columns[0]) == 0)
{
// bundle article found
if (qty < 0)
return columns[pos * 2];
else
return Convert.ToInt32(columns[1 + pos * 2]) * qty;
}
}
// in case no bundle article return the original values
if (qty < 0)
return InValues[1].GetValue();
else
return InValues[2].GetValue();
}
Best wishes
Robert Stark
Attachments:
Last edit: 8 years 2 weeks ago by FlowHeater-Team.
Please Log in or Create an account to join the conversation.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
8 years 2 weeks ago #2962
by JD Cox
Replied by JD Cox on topic Import Bundle Items - Post(2962)
Thank you, this works great thanks for the example too that really helped.
JD
JD
Please Log in or Create an account to join the conversation.
Time to create page: 0.266 seconds