Products are synced from the source application to Magento 2. Within this sync we can create or update products. APIcenter gathers the data from the source application, then it is run through the APIcenter to have the correct settings. Products are created or updated based on the SKU or EAN.
Simple and configurable products are supported when this data is sent from the source application.
- Allow orders at no stock
When turning on the setting “set_allow_orders_at_no_stock”, in Magento you need to turn on a setting that allows products to be set on in stock when the stock is lower than 1. In Magneto go to the menu and click on the item called
Stores, then under
settings click on
configuration. Then on the left a new menu will appear. In this menu select under
Catelog click on
Inventory. In here you need to change the setting
No backorders to
allow Qty Below 0. (You might need to deselect the checkbox to the right of this setting called
Use system value)
- Grouped products
In Apicenter you have the setting
This setting will switch the logic between grouped products and configurable products, basically grouped products are the same as configurable products but the differentation is made on sku and not on variables like size and colour for example. If the grouped product is created correctly there will be a “head” product that has the type grouped products and simple products related to it.
The second setting related to the reordering of the position based on sku is used for ordering the grouped products otherwise that can be randomized due to the way the data is delivered from the source
Please be aware that the source needs to provide the data in the same way they provide the data for a configurable product, so a parent with a variant relation. For grouped products you dont need to add attributes to make them unique.
Like any other application the approach for attributes and features is the same. First the presence of the attribuut is checked in magento and when this doesnt exist it will be created. After being created the attribute is then linked to the attribute set so it can be used on variants.
Next the value is checked to be present in Magento and in case it doesn’t exist yet it will be added to the attribute as well.
Supported attribute types:
There are serveral attribute types that are currently supported in Magento. The datamodel offers a type field on the attribute which can be used to specify the type to use for the attribute. If no type is specified the code will try to find the correct type. This is done by looking at the value of the attribute in the data and check this against this table:
|Attribute value||Handled like||Attribute type result|
|‘value’, ‘value’||Array||Multi select.|
|[‘string’, ‘string’]||Array||Multi select.|
|’true’ or ‘false’||Boolean 1/0||Select.|
|true or false||Boolean 1/0||Select.|
|‘only when type is in the data’||string||Text.|
|‘only when type is in the data’||string||TextArea.|
Please be aware that the type of the attribute will only be set when it is created.
There are 2 ways to search for the category. By default, the category is search for using its name. This can cause problems because some sub categories can have the same name for there categories. I.e. football->balls and handball->balls.
So a setting is made in which you can switch between searching by the name and search by the given category id. This category id needs to come from the get-flow.
The setting is called
use_search_on_category_id it be default turned off.
In our datamodel a new field was added called
category.id in here the id from the get side can be stored. On the magento side you need to add
When the id is filled and the setting is turned on we skip all the default code and ask magento to return the category with the given id.
Note: When an id is given that does not exist in Magento. Magento will return a hard error. We can not create a user-friendly error message because Magento will return a 400 error. In this example the id given was 2456789789564456564
Images and video is supported.
Now APIcenter only supports Youtube and Vimeo as URL providers.
Per default APIcenter supplies a mapping that makes sure you can send product data towards Magento. You can also make adjustments to this yourself.
Default fields that are mapped are for example:
- Long Description
- Short Description
- Price excl. tax or incl. tax
More information about data mapping can be found here.
|set_allow_orders_at_no_stock||Flow||Sets the product