Вы можете обрабатывать данные, полученные в веб-службе ресурса products
, и соответственно добавлять имя и значение функций продукта.
Вы можете сделать что-то, как показано ниже;
$xml = $webService->get(array(
'resource' => 'products',
'display' => 'full',
'filter[id_category_default]' => '[12|19|24|26]',
'filter[active]' => '[1]',
// 'limit' => 5,
'active' => '1'
));
foreach ($xml->products->product as $product) {
foreach ($product->associations->product_features->product_feature as $feature) {
$featureName = $webService->get(array(
'resource' => 'product_features',
'id' => $feature->id,
));
$featrueValue = $webService->get(array(
'resource' => 'product_feature_values',
'id' => $feature->id_feature_value
));
$feature->feature_name = $featureName->product_feature->name->language->__toString();
$feature->feature_value = $featrueValue->product_feature_value->value->language->__toString();
}
}
$resource = $xml->children()->children();
return $resource;
Добавлено feature_name
и feature_value
;см. результат ниже для справки, которая была добавлена в products
данных.
[product_features] => SimpleXMLElement Object
(
[@attributes] => Array
(
[nodeType] => product_feature
[api] => product_features
)
[product_feature] => Array
(
[0] => SimpleXMLElement Object
(
[id] => 5
[id_feature_value] => 5
[feature_name] => Compositions
[feature_value] => Cotton
)
[1] => SimpleXMLElement Object
(
[id] => 6
[id_feature_value] => 11
[feature_name] => Styles
[feature_value] => Casual
)
[2] => SimpleXMLElement Object
(
[id] => 7
[id_feature_value] => 17
[feature_name] => Properties
[feature_value] => Short Sleeve
)
)
)
Надеюсь, это поможет вам!