PS EventBus
<code>ps_eventbus</code> is a module companion for CloudSync.
Compatibility matrix
| PrestaShop platform | PHP | PS EventBus | | ------------------- | ---- | ----------------------- | | 8.0 | 7.1+ | From 2.x - to latest | | 1.7.3-1.7.8 | 7.1+ | From 2.x - to latest | | 1.6.1.11 - 1.7.2.5 | 5.6+ | From 3.1 - to latest |
PS Accounts compatibility matrix can be viewed here.
Product Images Issue in PHP 8.1
Please note that starting from PHP 8.1, product images may be missing due to a known issue. This is a recognized problem and is being tracked in the PrestaShop repository. You can follow the progress and find more details about the resolution here.
BREAKING CHANGES
Since version 4.0, all API endpoints are grouped under a single controller "apiShopContent.php" (except for the healthcheck). The route to call is now unique, and the shopContent is no longer a specific endpoint but a query parameter of the request: ``<code>http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=products<pre><code>
Use
</code></pre>sh make help # get help on how to use the awesome Makefile features make # bundle all vendors required for the module to run make zip # make a zip ready to be tested in PrestaShop (see ./dist) <pre><code> &gt; Pro-tip: prefix all you make commands with the variables you want to override. Ie: </code>VERSION=v1.2.3-rc4 make zip-prod<code> to set the zip package to the desired version.
Testing
</code></pre>sh make lint # linting the code with vendor/bin/php-cs-fixer make lint-fix # linting and fixing the code with vendor/bin/php-cs-fixer make php-lint # linting with php make phpunit # unit testing with vendor/bin/phpunit make phpunit-cov # unit testing as above but with code coverage make phpstan # linting the code with PrestaShop and vendor/bin/phpstan
make docker-<stuff> # same as above, but in a docker container <pre><code> &gt; Note: you will need xdebug if you want to generate the code-coverage of this project. You may install it with: </code>pecl install -f xdebug<code>.
Healthiness
To check the module healthiness (authenticated route):
</code></pre>sh BASE_URL="http://localhost:8000" curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", "ps_accounts_version": "5.6.2", "php_version": "7.1.33", "ps_account": true, "is_valid_jwt": true, "ps_eventbus": true, "env": { "EVENT_BUS_PROXY_API_URL": "http://reverse-proxy/collector", "EVENT_BUS_SYNC_API_URL": "http://reverse-proxy/sync-api" }, "httpCode": 200 } <pre><code> To check the fallback route (unauthenticated):
</code></pre>sh BASE_URL="http://localhost:8000" curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck" | jq . { "ps_account": true, "is_valid_jwt": true, "ps_eventbus": true, "env": { "EVENT_BUS_PROXY_API_URL": "http://reverse-proxy/collector", "EVENT_BUS_SYNC_API_URL": "http://reverse-proxy/sync-api", "EVENT_BUS_LIVE_SYNC_API_URL": "http://reverse-proxy/live-sync-api/v1" }, "httpCode": 200 } <pre><code>
Contribute
Dev requirements:
Or an up-to-date Docker engine.
How to add new shop content
Let&#039;s take the example of adding a shopContent named &quot;plane&quot;.
Add the shop content in the Config.php file (create a constant, and add it to the SHOP_CONTENTS array). </code></pre>PHP const COLLECTION_PLANES = 'planes';
const SHOP_CONTENTS = [ ... self::COLLECTION_PLANES ... ]; <pre><code> Create a service &quot;planesService.php&quot; (in plural) in the shop content services folder that extends the ShopContentAbstractService and implements the ShopContentServiceInterface.php interface. For the method structure, use the existing base on all other shop content services to maintain consistency. </code></pre>PHP class PlanesService extends ShopContentAbstractService implements ShopContentServiceInterface { ... } <pre><code>_Don&#039;t missing to declare this new service to ServiceProvider.php file._
Then create a repository PlaneRepository.php (in singular) in the Repository folder that extends the AbstractRepository.php class and implements the RepositoryInterface.php interface. Similarly, maintain consistency with other shop content repositories. </code></pre>PHP class PlaneRepository extends AbstractRepository implements RepositoryInterface { ... } <pre><code>_Don&#039;t missing to declare this new repository to RepositoryProvider.php file._
Add your shop content in the e2e config file. </code></pre>javascript export const shopContentMapping = { ... planes: 'planes' ... } </code>``
Run the tests once to generate the necessary dumps (they will be present in the dump folder). Once the test is performed (and failed), copy the planes.json file, and paste it into the fixture folder for your given version. Do the same for each version (if the versions return different results).
You can run the tests again and ensure everything is green.
In case your shopContent cannot return results (missing data in the tables), please add a planes.json file in the folders of each version containing an empty array.
List of missing data in a database and why is missing
| Object content | Reason | Added in PS version | Link with more info | |:----------------------------------:|:--------------------:|:-------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | currency.precision | row missing in table | 1.7.6.0 | github | | employee.has_enabled_gravatar | row missing in table | 1.7.8.0 | github | | product.additional_delivery_time | row missing in table | 1.7.3.0 | github | | product.delivery_in_stock | row missing in table | 1.7.3.0 | github | | product.delivery_out_stock | row missing in table | 1.7.3.0 | github | | stock.location | row missing in table | 1.7.5.0 | github | | store_lang | table missing | 1.7.3.0 | github | | wishlist¹ | table missing | n/a | Prestashop Addons | | taxonomy² | table missing | n/a | Prestashop Addons | | stock_available. physical_quantity | row missing in table | 1.7.2.0 | github | | stock_available. reserved_quantity | row missing in table | 1.7.2.0 | github | | languages.locale | row missing in table | 1.7.0.0 | github | | products.mpn | row missing in table | 1.7.7.0 | github |
¹ Feature enabled only with PsWishlist module</br> ² Feature enabled only with PsFacebook module
Debugging
There are 3 variables that are passed globally from the apiShopContent file to the end of the chain (repositories and errorHandler):
- PS_EVENTBUS_EXPLAIN_SQL_ENABLED
- PS_EVENTBUS_VERBOSE_ENABLED
- PS_EVENTBUS_LOGS_ENABLED
These variables are defined via the PHP function define() and reused in the files mentioned above. The reason for this usage is to avoid having to pass these variables through the entire execution chain to retrieve them at the end of the chain (e.g., apiShopContent => frontService => shopContentService => shopContentRepository).
Commenti (0)
Non è stato possibile inviare il tuo giudizio sulla recensione
Segnala commento
Segnalazione inviata
Non è stato possibile inviare la tua segnalazione