PrestaShop Connector - ItemUpdate
This function synchronizes item data from PrestaShop into the App4Sales platform. It retrieves product details, stock information, images, and specific pricing rules from the PrestaShop API. Only active and non-matrix products are processed. It runs on a scheduled basis, updating the App4Sales internal item database.
Data Source Configuration
Data is pulled from the PrestaShop API. The base URL for the API and the Application Key are configured in the connector settings.
Products: Fetched from the
/productsendpoint.Taxes: Fetched from the
/taxesand/tax_rulesendpoints.Stock: Fetched from the
/stock_availablesendpoint.Categories: Fetched from the
/categoriesendpoint.Specific Prices: Fetched from the
/specific_pricesendpoint.Images: Downloaded directly from
[PrestaShop_Base_URL]/images/products/[productId]/[imageId].
Data Mapping Table - Items
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| If the connector setting "Use Product Reference as Item Code" is enabled, the |
|
| Concatenation of the product name and description, separated by " - ". |
|
| The product's base price, converted to a decimal. |
| Derived | Hardcoded to 'E' (Exclusive). |
|
| Determined by looking up the product's |
|
| The product's EAN13 barcode. |
|
| The minimal quantity for purchase, converted to a decimal. |
| Derived | Hardcoded to "EUR". |
|
| The available stock quantity, converted to a decimal. Includes error handling for API changes. |
|
| The default image for the product is downloaded using its ID. The raw image data is stored. Includes error handling for download failures. |
|
| An |
Special Logic & Filters
Product Filtering: Only active products (
active = 1) are processed. Products identified as matrix items (havingassociations/combinations/combinations) are skipped.Stock Retrieval: Includes a
try-catchblock to handle potential API breaking changes in PrestaShop's stock available endpoint. If stock retrieval fails, the stock value remains unset.Image Download: The
DownloadImagehelper method handles fetching the image data from the PrestaShop URL. Exceptions during download are caught and ignored, meaning items will be synced without a picture if the download fails.Category Handling: The connector attempts to retrieve category IDs from two possible XML paths (
prestashop/product/associations/categories/categories/idandprestashop/product/associations/categories/category/id) to account for potential breaking changes in the PrestaShop API.Specific Price Caching: Specific prices from PrestaShop are processed, and their IDs are saved in the
KeySettingsContext, prefixed with "SpecificPrices_". This allows theOptA4SGetItemPriceForCustomermethod to efficiently retrieve customer-specific pricing information without re-fetching all specific prices. Specific prices with an expired 'to' date are skipped.
Domain Specifics
Price Logic
The base sales price is taken from prestashop/product/price. Tax percentages are applied based on PrestaShop's tax rules. Customer-specific and quantity-based pricing (specific prices) are handled by the OptA4SGetItemPriceForCustomer method, which checks for specific price rules linked to the product and customer. Discounts can be applied as either a fixed amount or a percentage.
Image Handling
The default product image is downloaded from the PrestaShop instance using its ID. The image is fetched directly from the URL [PrestaShop_Base_URL]/images/products/[productId]/[imageId]. No explicit resizing or compression logic is observed within this method; the raw image data is stored.
Stock & Availability
Stock is retrieved from the stock_availables endpoint. The quantity is taken from prestashop/stock_available/quantity. If there are issues retrieving stock, the item is still processed, but without stock information.
Matrix & Attributes
Matrix (variant) products are explicitly skipped by this update function. Item categorization is handled by creating an ItemClass named "Filters" and populating its values with the names of the PrestaShop categories associated with the product.
Related Settings & Prerequisites
Use Product Reference as Item Code: (
Settings.ProductReferenceAsItemCode) A boolean setting that determines whether the PrestaShop product 'reference' or the internal 'product ID' is used as the App4Sales Item Code.Application Key: (
Settings.Applicationkey) The API key required for authenticating requests to the PrestaShop API.PrestaShop Base URL: (
AdministrationSession.CurrentSession.Administration.Address) The base URL of the PrestaShop instance.
Known Limitations
This function explicitly skips matrix products; variant handling is not covered by this ItemUpdate method. The connector assumes a default currency of "EUR."