A Craft CMS plugin that manages Craft Commerce product variants from CSV files.
- Craft CMS
^5.0 - Craft Commerce
^5.0 - PHP
^8.2
From the Plugin Store, search for Variant Manager in Settings -> Plugins and press Install.
With Composer:
composer require fostercommerce/variant-manager
./craft plugin/install variant-managerWith DDEV:
ddev composer require fostercommerce/variant-manager -w && ddev exec php craft plugin/install variant-managerAfter install you will see a Variant Manager item in the CP navigation with two subnav entries: Dashboard and Variants.
Settings live in a config file, not the Control Panel. Create config/variant-manager.php:
<?php
return [
'emptyAttributeValue' => '',
'attributePrefix' => 'Attribute: ',
'inventoryPrefix' => 'Inventory',
'activityLogRetention' => '30 days',
'productFieldMap' => [
'*' => [
'title' => 'title',
'slug' => 'slug',
'status' => 'status',
],
],
'variantFieldMap' => [
'*' => [
'title' => 'title',
'sku' => 'sku',
'inventoryTracked' => 'inventoryTracked',
'price' => 'basePrice',
'height' => 'height',
'width' => 'width',
'length' => 'length',
'weight' => 'weight',
],
],
];Every key has a default; the plugin runs without the file. See configuration reference for what each key controls.
The plugin ships a Variant Attributes field type. Add it to every Commerce product type whose variants you want to import or export by attribute.
- Settings -> Fields -> New field.
- Set the Field Type to Variant Attributes. Give it a name and handle, for example
variantAttributes. The field has no settings of its own. - Commerce -> Settings -> Product Types -> {product type} -> Variant Fields and drag the field into the variant field layout.
Only one Variant Attributes field per variant field layout is read by the plugin. Additional copies are ignored.
See Variant Attributes field reference for how the field stores data.
Grant the plugin's permissions on user groups in Users -> {group} -> Permissions or on individual users:
variant-manager:import, upload CSVs and create or update products and variants.variant-manager:export, export products from the product edit page or the variants index.variant-manager:manage, clear the activity log and manage plugin data.
accessPlugin-variant-manager is required to see the plugin's CP section at all.
./craft variant-manager/activities/clearDeletes activity log entries older than activityLogRetention. Pass --all to wipe every entry regardless of age. Craft's garbage collection runs the same expiry pass automatically. See console commands.