Reputation: 1325
I need to obtain path and reference number from an api. I have working solution showed down there, but it loads too much data and that takes time.
$opt = array( 'resource' => 'products',
'display' => 'full' );
$xml = $webService->get($opt);
$productNodes = $xml->products->children();
$products = array();
foreach ($productNodes as $product) {
$reference = (string) $product->reference;
$path = $url.'/index.php?controller=product&id_product=' . $product->id;
$products[] = array('reference' => $reference, 'path' => $path);
}
Its probably because of $opt = array( 'resource' => 'products','display' => 'full' );
I've found that I can obtain only needed tables, but it's not working for reference
and path
tables, or could anybody tell me what's wrong?
$opt = array( 'resource' => 'products',
'display' => '[reference,path]' );
It returns following error:
Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request
Thanks a lot for your help.
Upvotes: 1
Views: 1095
Reputation: 1863
Replace path
(wrong field) on something else from the list
id, id_manufacturer, id_supplier, id_category_default, new, cache_default_attribute, id_default_image, id_default_combination, id_tax_rules_group, position_in_category, manufacturer_name, quantity, type, id_shop_default, reference, supplier_reference, location, width, height, depth, weight, quantity_discount, ean13, upc, cache_is_pack, cache_has_attachments, is_virtual, on_sale, online_only, ecotax, minimal_quantity, price, wholesale_price, unity, unit_price_ratio, additional_shipping_cost, customizable, text_fields, uploadable_files, active, redirect_type, id_product_redirected, available_for_order, available_date, condition, show_price, indexed, visibility, advanced_stock_management, date_add, date_upd, meta_description, meta_keywords, meta_title, link_rewrite, name, description, description_short, available_now, available_later
and/or check in response not only headers, but and xml body too that contains error message.
Upvotes: 2