I'm migrating data from another platform to magento.
I'm looping over each product and inserting the data i've generated.
$product = Mage::getModel('catalog/product')->load($p['magento_id']);
if(!$product->getOptionsReadonly()) {
$product->setProductOptions($pvars);
$product->setCanSaveCustomOptions(true);
$product->save();
}
what seems to be happening is that its adding the data, but also data from the previous inserts also, so i have multiple custom options called "Door Colour". the $pvar data is as it should be (see below).
$pvars contains:
Array
(
[83] => Array
(
[title] => Door Colour
[type] => drop_down
[is_require] => 1
[sort_order] => 0
[values] => Array
(
[0] => Array
(
[title] => Grey
[price] => 0.00
[price_type] => fixed
[sku] => 83-83-grey
[sort_order] => 1
)
[1] => Array
(
[title] => Dark Blue
[price] => 0.00
[price_type] => fixed
[sku] => 83-84-dark-blue
[sort_order] => 1
)
[2] => Array
(
[title] => Red
[price] => 0.00
[price_type] => fixed
[sku] => 83-85-red
[sort_order] => 1
)
[3] => Array
(
[title] => Maroon
[price] => 0.00
[price_type] => fixed
[sku] => 83-86-maroon
[sort_order] => 1
)
[4] => Array
(
[title] => Pastel Blue
[price] => 0.00
[price_type] => fixed
[sku] => 83-87-pastel-blue
[sort_order] => 1
)
[5] => Array
(
[title] => Yellow
[price] => 0.00
[price_type] => fixed
[sku] => 83-88-yellow
[sort_order] => 1
)
[6] => Array
(
[title] => Green
[price] => 0.00
[price_type] => fixed
[sku] => 83-89-green
[sort_order] => 1
)
)
)
[435] => Array
(
[title] => 11 Door Lock Option
[type] => drop_down
[is_require] => 1
[sort_order] => 0
[values] => Array
(
[0] => Array
(
[title] => Cam Locks (Free)
[price] => 0.00
[price_type] => fixed
[sku] => 435-90-cam-locks--free-
[sort_order] => 1
)
[1] => Array
(
[title] => Padlock Fitting (Free)
[price] => 0.00
[price_type] => fixed
[sku] => 435-91-padlock-fitting--free-
[sort_order] => 1
)
[2] => Array
(
[title] => 4 Digit Combination Locks
[price] => 253.00
[price_type] => fixed
[sku] => 435-92-4-digit-combination-locks
[sort_order] => 1
)
[3] => Array
(
[title] => £1 Coin Return Locks
[price] => 302.50
[price_type] => fixed
[sku] => 435-93---1-coin-return-locks
[sort_order] => 1
)
[4] => Array
(
[title] => Electronic Combination Locks
[price] => 495.00
[price_type] => fixed
[sku] => 435-94-electronic-combination-locks
[sort_order] => 1
)
)
)
[761] => Array
(
[title] => Size (mm)
[type] => drop_down
[is_require] => 1
[sort_order] => 0
[values] => Array
(
[0] => Array
(
[title] => 1800h x 1500w x 450d (11ARCH)
[price] => 0.00
[price_type] => fixed
[sku] => 761-95-1800h-x-1500w-x-450d--11arch-
[sort_order] => 1
)
)
)
)