jackmatt2 Posted August 24, 2010 Posted August 24, 2010 (edited) 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, 2010 by Guest
comment Posted August 24, 2010 Posted August 24, 2010 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.
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 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!!
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 (edited) @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, 2010 by Guest
comment Posted August 24, 2010 Posted August 24, 2010 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?
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 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
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 mmmm come to think of it that will not work either... any ideas?
comment Posted August 24, 2010 Posted August 24, 2010 Did you mean something like this? MergeByKey.zip
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 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.
comment Posted August 24, 2010 Posted August 24, 2010 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.
jackmatt2 Posted August 24, 2010 Author Posted August 24, 2010 @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
comment Posted August 24, 2010 Posted August 24, 2010 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?
Recommended Posts
This topic is 5205 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now