简体   繁体   English

使用 docker-compose 配置 Prestashop Web 服务

[英]Configure Prestashop Webservice using docker-compose

I am trying to simplify the installation of Prestashop by using docker containers.我试图通过使用 docker 容器来简化 Prestashop 的安装。 My issue is that the container must be API ready once loaded but I can't find a way to enable this feature from docker-compose.我的问题是容器必须在加载后准备好 API 但我找不到从 docker-compose 启用此功能的方法。

What I'm trying to accomplish:我要完成的工作:

  1. Enable Prestashop's Webservice启用 Prestashop 的 Web 服务
  2. Create a webservice key创建网络服务密钥
  3. Create permissions for the webservice为 Web 服务创建权限
  4. Be able to modify products, customers, addresses etc. from Postman能够从Postman修改产品、客户、地址等

Things I have done so far:到目前为止我做过的事情:

services:
    prestashopper:
        image: prestashop/prestashop
        ports:
            - 8080:80
        environment:
            - PS_LANGUAGE=en
            - PS_COUNTRY=CO
            - PS_FOLDER_ADMIN=admin_folder_name
            - PS_FOLDER_INSTALL=install_folder_name
            - PS_INSTALL_AUTO=1
            - PS_DOMAIN=localhost:8080
            - PS_WEBSERVICE=1
        command:
            [
            #     php -r 'Configuration::updateValue('PS_WEBSERVICE', 1);'
            #     php -r '$$apiAccess = new WebserviceKey();',
            #     php -r '$$apiAccess->key = GENERATED_KEY;',
            #     php -r '$$apiAccess->save();',
            ]

What my research has told me:我的研究告诉我:

Based on the documentation on the PrestaShop website, these commands can be done using PHP, however, I was unable to determine how to correctly run these PHP commands from a docker-compose setup根据 PrestaShop 网站上的文档,可以使用 PHP 完成这些命令,但是,我无法确定如何从 docker-compose 设置正确运行这些 PHP 命令

Also is it possible to modify the following from docker-compose也可以从 docker-compose 修改以下内容

  • Modify currency options修改货币选项
  • Change shop's main activity换店的主要活动

You'll need a dedicated PHP script in your container or mounted volume where you need to bootstrap Prestashop framework (include /init.php and /config/config.inc.php ) so you can launch those Prestashop core commands afterwards.你需要一个专用的 PHP 脚本在你需要引导 Prestashop 框架的容器或挂载卷中(包括/init.php/config/config.inc.ZE1BFD762321E409CEE4AC0B6E84196之后你可以启动这些 Prestashop 命令)

You can use docker exec to execute it after cointaner had started:您可以在 cointaner 启动后使用 docker exec 执行它:

docker exec -it -w $PWD php_worker php /home/my_post_install_script.php

Regarding modify currency options, have a look at classes/Currency.php , there all all the methods to interact with Currency object.关于修改货币选项,请查看classes/Currency.php ,所有与 Currency object 交互的方法。

Regarding updating shop main activity, this is the PS_SHOP_ACTIVITY key in Configuration table, so a关于更新商店主要活动,这是配置表中的PS_SHOP_ACTIVITY键,所以

Configuration::updateValue(PS_SHOP_ACTIVITY, your_id) 

will do the trick.会成功的。 You can find various option values in backoffice dropdown list.您可以在后台下拉列表中找到各种选项值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM