php-etl/prestashop-expression-language
Composer 安装命令:
composer require php-etl/prestashop-expression-language
包简介
This library implements functions for manipulating Prestashop data in ExpressionLanguage
README 文档
README
This package extends the ExpressionLanguage Symfony component to manipulate data coming from Akeneo into valid Prestashop data.
Documentation
Installation
composer require php-etl/prestashop-expression-language
Usage
You can use these expressions in your configuration files as in the following example :
foo: '@=booleans(my_akeneo_attribute_code: {the_akeneo_value_to search for: the_prestashop_id_replacement})'
Attribute functions
Functions that turn an Akeneo attribute into a Prestashop attribute_option_value.
booleans
# input {values: {new_collection: [{scope: null, data: true}]}} #function field: '[associations][product_option_values][product_option_value]' expression: 'booleans({ new_collection: {true: 52, false: 53} })' #output <associations> <product_option_values> <product_option_value> <id>52</id> </product_option_value> </product_option_values> </associations>
lists
# input {values: {categories: ["spring", "summer"]}} #function field: '[associations][product_option_values][product_option_value]' expression: 'lists({ categories: {spring: 74, autumn: 75, summer: 76} })' #output <associations> <product_option_values> <product_option_value> <id>74</id> </product_option_value> <product_option_value> <id>76</id> </product_option_value> </product_option_values> </associations>
measurements
# input {values: {weigth_net: {scope: null, data: {amount: "341.000"}}}} #function field: '[associations][product_option_values][product_option_value]' expression: 'measurements({ weigth_net: {"340.000": 21, "341.000": 22, "342.000": 23} })' #output <associations> <product_option_values> <product_option_value> <id>22</id> </product_option_value> </product_option_values> </associations>
scalars
# input {values: {color: {scope: null, data: "navy_blue"}}} #function field: '[associations][product_option_values][product_option_value]' expression: 'scalars({ navy_blue: {salmon: 39, citrus: 40, navy_blue: 41, anthracite: 42} })' #output <associations> <product_option_values> <product_option_value> <id>41</id> </product_option_value> </product_option_values> </associations>
Features function
Function that turns an Akeneo attribute into a Prestashop feature.
booleanAttributeToFeature
# input {values: {color: true, varnish: false}} # function - field: '[associations][product_features]' expression: > booleanAttributeToFeature([ { akeneo_code: 'color', prestashop_id: 16, values: { true: 120, false: 121, } }, { akeneo_code: 'varnish', prestashop_id: 20, values: { true: 63, false: 64 } } ]) # output <associations> <product_features> <product_feature> <id>16</id> <id_feature_value>120</id_feature_value> </product_feature> <product_feature> <id>20</id> <id_feature_value>64</id_feature_value> </product_feature> </product_features> </associations>
mapFeatures
# input {id_feature_value: '23,24,25', id: 17} # function - field: '[associations][product_features]' expression: 'mapFeatures(lookup)' # output <associations> <product_features> <product_feature> <id>23</id> <id_feature_value>17</id_feature_value> </product_feature> <product_feature> <id>24</id> <id_feature_value>17</id_feature_value> </product_feature> <product_feature> <id>25</id> <id_feature_value>17</id_feature_value> </product_feature> </product_features> </associations>
features
# input {values: {norm: {scope: null, data: "ean188"}}} #function field: '[associations][product_features]' expression: > features([ { akeneo_code: 'norm', prestashop_id: 15, values: { ean144: 97, ean1502_b: 98, ean188: 99, } } ]) #output <associations> <product_features> <product_feature> <id>15</id> <id_feature_value>99</id_feature_value> </product_feature> </product_features> </associations>
mapIds
# input {1,2,3} # function - field: '[categories]' expression: 'mapIds(input)' # output <categories> <id>1</id> <id>2</id> <id>3</id> </categories>
splitAndTrim
# input {' Foo, bAr ,BAZ'} # function - field: '[words]' expression: 'splitAndTrim(",", input)' # output <words> <0>foo</0> <1>bar</1> <2>baz</2> </words>
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-27