Jump to content

How to automate Webservice 1.7/8 configuration?


noemx

Recommended Posts

Hi,

I would like to automate Webservice configuration for PS 1.7 or 8 to allow automated test environment setup. The goal is to:

  • Enable Webservice
  • Add the Webservice key with all the permissions there are

I've explored /bin/console but that doesn't seem to be able to do that, so I came here to ask.

My last resort plan is to diff a DB dump before/after webservice configuration to see what SQL to apply to enable it, but I would like to avoid this (its ugly and could be version dependent).

Would you have any hints how to achieve this?

Link to comment
Share on other sites

I think your last plan is the most feasible.
Find out the SQL and collect it, and import it every time you need to test. As long as it is not a big version of PrestaShop upgrade, Webservice generally does not change, so you don't need to worry too much.
It is good to do a necessary check every time you import SQL.

Link to comment
Share on other sites

  • 2 weeks later...

I got one step further, so posting progress. I'm actually able to enable webservice via bin/console like this:

php bin/console prestashop:config --value 1 set PS_WEBSERVICE
php bin/console prestashop:config --value 1 set PS_WEBSERVICE_CGI_HOST

And add webservice key and permissions via SQL:

INSERT INTO `ps_webservice_account` VALUES (1,'QWERTYUIOPASDFGHJKLZXCVBNM123456','My key name','WebserviceRequest',0,NULL,1)
INSERT INTO `ps_webservice_account_shop` VALUES (1,1)
INSERT INTO `ps_webservice_permission` VALUES (837,'addresses','GET',3)
INSERT INTO `ps_webservice_permission` VALUES (838,'addresses','POST',3)
INSERT INTO `ps_webservice_permission` VALUES (839,'addresses','DELETE',3)
...

Didn't test this yet though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...