Hello,
The below script should do the work.
Please test it in a staging environment first. Or with some test combinations.
You will need to provide the combination ids in that array and the id of the new attribute that will be added to them. This is the id of the attribute and not the id of the attribute group. You can get it by going to Attributes and Features, and select the desired attribute group (e.g. Size), then you will have a list of all the size attributes - pick the one you want.
As per usual, for running the script, create a file called script.php (or any other name you want), copy the below code inside it, modify it to fulfill your needs and access <website_url>/script.php
<?php require dirname(__FILE__) . '/config/config.inc.php'; $combinationIds = [44, 45, 46, 47]; $newAttributeId = 6; foreach ($combinationIds as $id) { $combination = new Combination($id); $attributeIds = []; $existingAttributes = $combination->getAttributesName(1); foreach ($existingAttributes as $attribute) { $attributeIds[] = $attribute['id_attribute']; } if (in_array($newAttributeId, $attributeIds)) { continue; } $attributeIds[] = $newAttributeId; $combination->setAttributes($attributeIds); $combination->save(); } echo 'All set!';
Let me know if it works or if you have any issues with it.