Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

php - Configure Prestashop Webservice using docker-compose

I am trying to simplify the installation of Prestashop by using docker containers. 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.

What I’m trying to accomplish:

  1. Enable Prestashop's Webservice
  2. Create a webservice key
  3. Create permissions for the webservice
  4. Be able to modify products, customers, addresses etc. from 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

Also is it possible to modify the following from docker-compose

  • Modify currency options
  • Change shop's main activity
question from:https://stackoverflow.com/questions/65878504/configure-prestashop-webservice-using-docker-compose

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

You can use docker exec to execute it after cointaner had started:

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.

Regarding updating shop main activity, this is the PS_SHOP_ACTIVITY key in Configuration table , so a

Configuration::updateValue(PS_SHOP_ACTIVITY, your_id) 

will do the trick. You can find various option values in backoffice dropdown list.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...