如何将 prestashop 与 android 整合?

How to integrate prestashop with android?

最近我使用 prestashop 创建了一个 eshop 网站

https://www.prestashop.com/en/

因为我要为它构建 android 应用程序。应用程序中包含的只是一些基本功能

例如创建客户帐户/列出产品/订购产品/支付/查看订单等..common eshop功能...

问题是好像资源太少了。是否已经有任何图书馆/官方图书馆/或者我需要从 stratch 开始创建 API?

阅读 http://doc.prestashop.com/display/PS16/Developer+Guide 有一段时间但不知道我需要从什么开始。

这是一个很抽象的问题,但由于社区不是很受欢迎,而且资源有限,我希望这可以借鉴其他人的经验,并帮助有同样要求的其他人。

非常感谢您的帮助

如果您不是在寻找原生应用,您可能想尝试响应式 mobile template addon or paid themes. If you need a native app and would like to reuse APIs from your prestashop store, you will have to create an access to Prestashop REST webservices

要测试您是否已正确配置对 Web 服务的访问,请转到页面 http://mypasskey@mystore.com/api/,其中 "mypasskey" 已替换为您的密钥。

The problem is it seems there are few resources around. Is there any library already there/ offical one / or I need to start create the API from stratch?

与您的问题的评论之一相反,Prestashop 实际上提供 REST 服务。在文档中它是由 "web service".

引用的

快速链接:

有一些 open source API implementations 可用,但 none 专门用于 Android/Java。不过,您可能会发现它们作为指南很有用。

需要注意的几点:

默认情况下,Web 服务功能似乎处于禁用状态。因此,为了使用它,您必须先在后台启用它。从文档中复制:

Enabling the webservice feature

Go in the PrestaShop back-office, open the "Webservice" page under the "Advanced Parameters" menu, and then choose "Yes" for the "Enable PrestaShop's webservice". Save your change: you're done!

与 Web 服务通信需要 API 密钥。您必须为您的 Android 应用生成一个,再次使用后台:

Creating an access key

Open the "Webservice" page under the "Advanced Parameters" menu, and then click the "Add New" button to access the account configuration section. A long form appears:

  • Key. The API key serves as the main identifier for the webservice account you are creating. Click the "Generate" button to get an unique authentication key. You can also create your own (which must be 32 characters long), but using a generated key prevents wrong-doers from guessing your key too easily. Using this key, you and other selected users will be able to access the webservice.
  • Key description. Helps you remember who you created that key for, what are the access rights assigned to it, etc. The description is not public, but make sure to put all the keywords pertaining to the user, so that you can find their key more quickly.

  • Status. You can disable any key at any time.

  • Permissions. This section is very important, as it enables you to assign rights for each resource you want to make available to this key. Indeed, you might want a user to have read and write access on some resources, but only read access on others – and no access to the more important ones. In the list of permissions, the checkbox most on the left enables you to define all the rights for a given resource. Likewise, the checkbox at the top of each column enables you to give the select right (View, Modify, etc.) to all the resources. Make sure to only select the rights needed for the usage of that key. Do not give all the rights for all resources to any key, keep that to yours and yours only. Shop association. This only appears in multistore mode. It enables you to choose which of your stores the key owner should have access to.

If you choose to use a custom passkey instead of a generated one, make sure it is very secure and that its rights are limited – and that it is 32characters long!

最后,概述 API 方法:

Accessing the webservice from the browser

The endpoint to your store's webservice is located in the /api/ folder at the root of your installation of Prestashop:

To access it, you need to provide your API key when request. There is no password, providing your API key is enough – and therefore the key should be kept secret by the user! You can either type the API endpoint address directly then enter your API key, or indicate your API key in the address. Here is an example, with UCCLLQ9N2ARSHWCXLT74KUKSSK34BFKX being the API key.

You can test this with any browser that supports XML. If no permission has been set for the key, then the browser will keep asking you to enter the key indefinitely.

结果应该看起来像这样(对于 PrestaShop 1.5.4.1 版):

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <api shop_name="MYSHOP">
    <addresses>...</addresses>
    <carriers>...</carriers>
    <cart_rules>...</cart_rules>
    <carts>...</carts>
    <categories>...</categories>
    <combinations>...</combinations>
    <configurations>...</configurations>
    <contacts>...</contacts>
    <content_management_system>...</content_management_system>
    <countries>...</countries>
    <currencies>...</currencies>
    <customer_messages>...</customer_messages>
    <customer_threads>...</customer_threads>
    <customers>...</customers>
    <deliveries>...</deliveries>
    <employees>...</employees>
    <groups>...</groups>
    <guests>...</guests>
    <image_types>...</image_types>
    <images>...</images>
    <languages>...</languages>
    <manufacturers>...</manufacturers>
    <order_carriers>...</order_carriers>
    <order_details>...</order_details>
    <order_discounts>...</order_discounts>
    <order_histories>...</order_histories>
    <order_invoices>...</order_invoices>
    <order_payments>...</order_payments>
    <order_states>...</order_states>
    <orders>...</orders>
    <price_ranges>...</price_ranges>
    <product_feature_values>...</product_feature_values>
    <product_features>...</product_features>
    <product_option_values>...</product_option_values>
    <product_options>...</product_options>
    <product_suppliers>...</product_suppliers>
    <products>...</products>
    <search >...</search>
    <shop_groups>...</shop_groups>
    <shops>...</shops>
    <specific_price_rules>...</specific_price_rules>
    <specific_prices>...</specific_prices>
    <states>...</states>
    <stock_availables>...</stock_availables>
    <stock_movement_reasons>...</stock_movement_reasons>
    <stock_movements>...</stock_movements>
    <stocks>...</stocks>
    <stores>...</stores>
    <suppliers>...</suppliers>
    <supply_order_details>...</supply_order_details>
    <supply_order_histories>...</supply_order_histories>
    <supply_order_receipt_histories>...</supply_order_receipt_histories>
    <supply_order_states>...</supply_order_states>
    <supply_orders>...</supply_orders>
    <tags>...</tags>
    <tax_rule_groups>...</tax_rule_groups>
    <tax_rules>...</tax_rules>
    <taxes>...</taxes>
    <translated_configurations>...</translated_configurations>
    <warehouse_product_locations>...</warehouse_product_locations>
    <warehouses>...</warehouses>
    <weight_ranges>...</weight_ranges>
    <zones>...</zones>
  </api>
  <api shop_name="MYOTHERSHOP">...</api>
  <api shop_name="YETANOTHERSHOP">...</api>
</prestashop>

既然您提到您主要对支持 Android 应用程序中的 basic/core 功能感兴趣,我倾向于说这可能符合您的需求。 :)