Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5205 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (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 by Guest
Posted

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.

Posted

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!!

Posted (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 by Guest
Posted

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?

Posted

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

Posted

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.

Posted

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.

Posted

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.