August 24, 201015 yr I have three tables Products: id, name, category_id, description Categories: id, html_template CategoryFields: id, category_id, key, value The relationships have all been setup properly. In Categories::html_template I will have something like this {name} {size} {length} {width} now each of the keys (name, size, lenght & width) will be entered via the CategoryFields table. So every Category will have a different set of keys. Inside the Products table I set they key values using a portal. For example name = "T-Shirt" size = "M" length = "50cm" width = "100cm" I have a button that will copy the Categories::html_template into Products::description. I then need it to do a "find and replace" on all the CategoryFields keys (and appending the "{" and "}" ) and then replacing it with the values. So in the above example, the result would be T-Shirt M 50cm 100cm I got this working for fields references inside the products table but am unsure about how to loop over all related CategoryFields. What script steps should I use to loop over all related records, perform the find and replace and then exit when there are no more keys to replace? Edited August 24, 201015 yr by Guest
August 24, 201015 yr Inside the Products table I set they key values using a portal. For example name = "T-Shirt" size = "M" length = "50cm" width = "100cm" A portal to which table?? Perhaps it would be better if you post an example file.
August 24, 201015 yr Author Well this really sucks but I can't get the size of the file below 1.05M which is required to upload to this site. I have even tried zipping with and creating a clone with no success. The Administrators really need to change the upload limit!!
August 24, 201015 yr Author @comment you can download it from here http://droidprofessor.com/tmp/ebayInventory.zip The script I am editing is called "Product Description from Template" If you go into the products layout you can run it by pressing the button Edited August 24, 201015 yr by Guest
August 24, 201015 yr Something doesn't make sense here: are ALL products in the 'T-Shirt' category of the SAME size, length and width? If yes, why isn't the Description field in the Category record?
August 24, 201015 yr Author I was just looking at that myself and thinking that I should reference the products table, not the category table. I will fix it and upload the link, just give me a second
August 24, 201015 yr Author Almost, but what I want if for the Category to control fields. So if I choose a category of T-Shirt, the available fields will display automatically. I could have 100 different products of type T-Shirt and all would share the same keys, however the values would be different for each product.
August 24, 201015 yr Well, that's an entirely different issue. One way to do this is to script the creation of new product records, and create the required related records at this time.
August 24, 201015 yr Author @comment I have fixed that problem and now I am back at the initial question, looping through all the related records and replacing the key with the value. I put the new file back up at http://droidprofessor.com/tmp/ebayInventory.zip
August 24, 201015 yr I am back at the initial question, looping through all the related records and replacing the key with the value. Doesn't my file do just that?
Create an account or sign in to comment