1-如果我这样写这条线;我使用的API(magento 2 rest api)不接受 category_ids 值:
$cat = '["34","22","14"]';
array( 'attribute_code' => 'category_ids', 'value' => $cat),
2-如果我写这样的行; API未再次保存 category_ids :
array( 'attribute_code' => 'category_ids', 'value' => '["34","22","14"]'),
3-但如果我这样写;一切都很好:
array( 'attribute_code' => 'category_ids', 'value' => ["34","22","14"]),
我必须将 category_ids 值写为变量;那么,有人可以帮我写出正确的语法吗?
答案 0 :(得分:0)
您不应将数组放在single quotes
内。
// Change this
$cat = '["34","22","14"]';
// to this
$cat = ["34","22","14"];