Configure Prestashop Webservice using docker-compose

Viewed 288

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
1 Answers

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.

Related