Display All Attribute Names
Last updated
Last updated
To view the values of a Product Template's attributes in SharpSync, use the Property Mapping list product.attribute
(see also )
The list product.attribute
is special in that you can expand upon the query by adding attribute name at the end in square brackets. See Display Single Attribute Names
Start by adding a for
product.template.attributes
Primary Accessor
(Unmapped)
Secondary Accessor
product.template.attributes
List Name
product.attribute
List Value Selector
{id}:{name}
Prefer Odoo Value
checked
Update Odoo on submit
! enable only if mapping a single value !
[You have been warned!]
Open the Property Mapping > Settings and enter a List Name
of
product.attribute
Click the Save
button. The list preview will update and show values like this
From this list, you can pick individual key/value pairs like id
and name
as a List Value Selector
Change the List Value Selector
to
{id}:{name}
Click the Save button, then the refresh button next to the list preview.
This will shorten the list to
1:Legs|2:Color|3:Duration|5:Finish
We have the information we need, lets make this dynamic in the SharpSync Bill of Material view
We have the values returned from the above list is as follows:
1:Legs|2:Color|3:Duration|5:Finish
This means each attribute has an internal id `id`, and a display name or 'name' value associated with the id value. Our next step is convert this list to a list of JSON objects in the form
[
{ "id" : "id1Value" , "name" : "displayName1" },
{ "id" : "id2Value" , "name" : "displayName2" }
]
Convert the following string into a JSON array with "id" and "name" key value pair objects. The keys must be integers
Click the copy button next to the generated list of values
In SharpSync make the following changes to the Property Mapping:
Rendering Type
Advanced Multi Select List
List Display Selector
name
List Value Selector
id
List Items
Click the save button
You now have the values in the list, but nothing will yet display in the Bill Of Materials view.
The next step will be to parse the values from Odoo so that it automatically selects the correct value onscreen when the BOM is loaded from Odoo.
The values that arrive from Odoo are complex nested values (the type is nestedObject
in SharpSync) and looks something like this:
This must be converted this to a more readable format for the BOM comparison screen, so we'll make use of an import rule
.
Navigate to the Property Mapping. Add a new Import Rule:
Rule Type
Import
Rule Name
Text Manipulation
Value
Enabled for
Odoo only
This will return a string of 'ids' as a result, select the values from the list of values to the screen, and return the selected values
You can create this by hand or use the following handy prompt in or with your text string pasted after: