Introduction
This section describes how the module maps products to Shopware and what configuration options are available. If you are interested in mapping product variants please refer to the variant-mapping documentation.
Subsections
The following subsections are involved in mapping products:
output
└───product
└───product-build-cache
└───product-anomaly-delta-count
└───product-anomaly-check
└───product-validate
└───product-validate-variants*
└───product-upsert
└───product-upsert-variants*
└───product-delete
*
Please refer to the variant-mapping documentation
Configuration
{
"subsections": {
"product": {
"enabled": false,
"deleteMode": "...",
"warehouses": [
"..."
],
"mapVariants": false
}
}
}
The field mapVariants
is used to activate the mapping of product variants. Please refer to
the product-variant mapping documentation.
Mapping Table
Target: product
Source: Elio\CommerceBundle\Document\Product\Product
Target Field | Source Path |
---|---|
* tax_id |
taxGroup.identifier referenced entity searched by tax.custom_fields.{{SICF}} |
manufacturer_id | manufacturer.identifier referenced entity searched by product_manufacturer.custom_fields.{{SICF}} |
unit_id | basePriceCalculation.baseUnit.abbreviation referenced entity searched by unit.translations.short_code or unit.custom_fields.{{SICF}} |
active | active |
* price |
defaultPrice.netPrice or productPriceLists see "Product Price Mapping" |
manufacturer_number | productIdentifiers.mpn |
ean | productIdentifiers.ean |
* product_number |
identifier |
* stock |
availability.warehouses see "Stock Mapping" |
is_closeout | availability.clearanceSale |
purchase_steps | availability.purchaseSteps |
max_purchase | availability.maxOrderQuantity |
min_purchase | availability.minOrderQuantity |
purchase_unit | basePriceCalculation.sellingQuantity |
* reference_unit |
basePriceCalculation.baseQuantity |
weight | packageDimensions.weight.value Unit is converted to mm automatically |
width | packageDimensions.width.value Unit is converted to mm automatically |
height | packageDimensions.height.value Unit is converted to mm automatically |
length | packageDimensions.length.value Unit is converted to kg automatically |
* release_date |
generalInformation.publicationDate |
*T name |
generalInformation.name |
T description |
generalInformation.description |
T keywords |
generalInformation.metaInformation.metaKeywords |
T meta_description |
generalInformation.metaInformation.metaDescription |
T meta_title |
generalInformation.metaInformation.metaTitle |
T pack_unit |
packageDimensions.packageUnit.name |
T pack_unit_plural |
packageDimensions.packageUnit.namePlural |
categories | categoryRelations |
tags | tags |
properties | propertyOptionCollection |
visibilities | channels |
Product Prices
Two types of product prices are supported: "normal" prices and currency dependent prices.
"Normal" Prices
To map "normal" prices the attribute Product::defaultPrice
must be set. This price will be assigned to the default currency of the
shop.
Currency Aware Prices
In order to map a single currency aware price to Shopware you have to create a currency aware price list that in turn contains a single price for the target currency in the data model. Example:
$product->setProductPriceLists(
new ArrayCollection(
[
CurrencyAwarePriceListFactory::makeSingleList(iso: 'EUR', netPrice: 20, pseudoPrice: 25),
CurrencyAwarePriceListFactory::makeSinglePriceList(iso: 'USD', sellingPrice: new SellingPrice(25, 30))
]
)
);
see Elio\CommerceBundle\Util\Product\Price\Lists\CurrencyAwarePriceListFactory
To verify the resulting prices in Shopware you can go to admin -> product -> prices -> currency dependent pricing
. For this example
the output will be the following:
Stocks and Warehouses
You can manage stocks on your products in this way:
$warehouseStocks = new WarehouseStock(50);
$warehouse = new Warehouse('myWarehouse', new ArrayCollection([$warehouseStocks]));
// new product
$product = new Product('myProduct');
$product->setAvailability(new Availability(new ArrayCollection([$warehouseStocks])));
// existing product
$product->getAvailability()->addWarehouse($warehouse);
The configuration for stocks has the following structure:
{
"subsections": {
"product": {
"enabled": true,
"deleteMode": "hard",
"warehouses": [
"myWarehouse"
]
}
}
}
warehouses
defines the names of the warehouses that are used to calculate the stock. Without configuration all warehouses are used.
The module requires at least one mapped warehouse to be available on a product, otherwise it will be flagged as invalid.
Base Price Calculation, Units and Dimensions
The mapping between Shopware and the data model can be a bit confusing, especially for units and reference units. So we'll break it down in detail here. In the backend of Shopware you can find the section "Measures & Packaging" on the "Specifications" tab of the product detail page:
As you can see the corresponding source paths were added to that figure.
Dimensions
The package dimensions are actually pretty straight forward:
Backend Field | Table Column | synQup Field |
---|---|---|
Weight | weight | packageDimensions.weight.value Unit is converted to kg automatically |
Width | width | packageDimensions.width.value Unit is converted to mm automatically |
Height | height | packageDimensions.height.value Unit is converted to mm automatically |
Length | length | packageDimensions.length.value Unit is converted to mm automatically |
The only thing to consider for weights is that only g
and kg
are supported as unit.
Units
Backend Field Name | Table Column Name | synQup Field Name |
---|---|---|
Selling unit | purchase_unit | basePriceCalculation.sellingQuantity |
Scale unit | unit_id | basePriceCalculation.baseUnit |
Packaging unit | pack_unit | packageDimensions.packageUnit.name |
Packaging unit plural | pack_unit_plural | packageDimensions.packageUnit.namePlural |
Basic unit | reference_unit | basePriceCalculation.baseQuantity |
basePriceCalculation.baseUnit
is extracted from products in the extract-embedded-product-info
subsection. The unit will be mapped
as UnitEntity
to the unit
table.
Example
The following figure contains a product with all units, dimensions and packaging units:
# width, height, length, and weight
$cm = $this->unitDefinitionService->getUnit(UnitDefinition::CENTIMETER);
$kg = $this->unitDefinitionService->getUnit(UnitDefinition::KILOGRAM);
$width = new Dimension(1, $cm); # will be converted to mm automatically
$height = new Dimension(2, $cm); # will be converted to mm automatically
$length = new Dimension(3, $cm); # will be converted to mm automatically
$weight = new Dimension(4, $kg);
# selling unit
$sellingUnit = 5;
# scale unit
$scaleUnit = new Unit(
abbreviation: 'pt.',
name: TranslationCollection::create([Locale::en_GB, 'part']),
namePlural: TranslationCollection::create([Locale::en_GB, 'parts']), # name plural
);
# packaging unit and packaging unit plural
$packagingUnits = new Unit(
'pc', # abbreviation - this value is actually ignored
TranslationCollection::create([Locale::en_GB, 'piece']), # name
TranslationCollection::create([Locale::en_GB, 'pieces']) # name plural
);
# basic unit
$basicUnit = 6;
# combine values
$product->setPackageDimensions(new PackageDimensions($width, $height, $length, $weight, $packagingUnits));
$product->setBasePriceCalculation(new BasePriceCalculation($basicUnit, $sellingUnit, $scaleUnit));
The result in the administration panel looks like this: