Dynamic data import / export

datenbank

simply more productive
Up to 10,000 records can be processed with the freeware version!
Welcome, Guest
Username: Password: Remember me
Welcome to the FlowHeater support forum.

Questions about using FlowHeater are answered here.
  • Page:
  • 1

TOPIC: Import Bundle Items

Import Bundle Items 1 month 3 weeks ago #2959

  • JD Cox
  • JD Cox's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 39
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

Please Log in or Create an account to join the conversation.

Import Bundle Items 1 month 2 weeks ago #2961

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 242
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
// 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();
}

File Attachment:

File Name: replace-bundle-orders.zip
File Size: 3 KB
Attachments:

Please Log in or Create an account to join the conversation.

Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Last Edit: by FlowHeater-Team.

Import Bundle Items 1 month 2 weeks ago #2962

  • JD Cox
  • JD Cox's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 39
Thank you, this works great thanks for the example too that really helped. :)

JD

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: FlowHeater-Team
Time to create page: 0.090 seconds