Since I use a lot of script type attributes, which make use of the ‘pav’ function in Core 1.x, I have to convert all those scripts to get them ready for Core 2.x.
Basically, it works this way:
The old script section
{% set value = pav('attributeCode') %}
{% set valueUnit = findRecord('Unit', {'id': value.referenceValue }) %}
is now changed to
{% set product = entity | putAttributesToEntity %}
{% set value = product.attributeCodeValue %}
{% set valueUnit = findEntity('Unit', {'id': product.attributeCodeValueUnitId}) %}
In the end, I will create an AI prompt to get all the script type attributes converted and prepared for AtroCore 2.x.
So my question is: Are there any other changes I have to do, especially on some attribute types (including “advanced data type” attributes)?
Thank you for your feedback!
There are several types of attributes whose values can be stored in multiple fields and which you may need to review in your scripts, such as range int/range float, link.
For the first ones, the values can be obtained as follows:
{% set valueFrom = product.attributeCodeValueFrom %}{% set valueTo = product.attributeCodeValueTo %}
For link attributes:
{% set valueId = product.attributeCodeValueId %}{% set valueName = product.attributeCodeValueName %}
Also, pay attention to the attributesDefs object, which is located in the product or other entities for which attributes are available, describing all virtual fields associated with attributes. It can help you in the future when writing scripts.
Thank you for the starting point, this is very helpful but also a little confusing
When I look into the attributeDefs part, there’s no ValueFrom/ValueTo but From/To added to the attribute’s code (without the Value added before). The PAVs at the end of the product’s JSON are listet the same way - so I shouldn’t use ValueFrom/ValueTo but From/To.
Is this correct or should I use ValueFrom/ValueTo (meaning that I always should add Value and then From, To,Id depending on type)?
Could you please list the “special case” attribute types and what I should append to Value for the relevant type?