Prestashop - API仅获取选定的值而不是“display = full”

时间:2015-10-26 15:00:03

标签: api prestashop

我需要从api获取路径和参考号。我有工作解决方案显示在那里,但它加载太多的数据,这需要时间。

$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);
  }

可能是因为$opt = array( 'resource' => 'products','display' => 'full' );我找到了that I can obtain only needed tables,但它不适用于referencepath表,或者有人可以告诉我出了什么问题?

 $opt = array( 'resource' => 'products',
                'display'  => '[reference,path]' );

它返回以下错误:

未捕获的异常'PrestaShopWebserviceException',带有消息'对PrestaShop Web服务的此调用失败并返回HTTP状态400.这意味着:错误请求

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:2)

从列表中的其他内容替换path(错误的字段)

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

和/或检查响应不仅是标题,而且还包含错误消息的xml正文。