Simple function for Configurable product in Magento

Completed Posted Jun 8, 2011 Paid on delivery
Completed Paid on delivery

Job Description :

I have a configurable product in Magento. It is in the object $myproduct

The product may be new (ie not saved yet) or it may be an existing configurable product with colour/size attributes attached.

I need a function with the following parameters

function setMyConfigurableAttributes(&$product, $attributeArray)

// $product is the Configurable product object (passing by reference)

// $attributeArray is an array of the ID’s of Magento attributes that will be configurable on this product

The size of the array could be 1, 2 or 3 elements

Sample calls :

setMyConfigurableAttributes($myproduct, array(12,15)); // would make the configurable attributes 12 and 15

setMyConfigurableAttributes($myproduct, array(9,8,10)); // remove any existing configurable attributes and change to 9 and 8 and 10

setMyConfigurableAttributes($myproduct, array()); // would remove any existing configurable attributes (may not make sense – ignore if this is not possible)

In the examples shown above, the numbers 8,9,10,12 and 15 are Magento ID numbers for the required attributes (eg Colour/Size/Style etc)

I think the Magento function I need to use is $product->setConfigurableAttributesData, but I don’t know how to use it. I also think I may need $product->setCanSaveConfigurableAttributes(true), but I am unsure on this.

I do not need any test cases. The code is being spliced into an existing program

If it is not possible to change the configurable attributes on an existing product, I can write code to delete the product and create a new product before it is passed into setMyConfigurableAttributes to make it easier.

The resulting code must use Magento Objects. It cannot use direct database read/write

Magento PHP

Project ID: #1091155

About the project

1 proposal Remote project Active Jun 8, 2011

Awarded to:

Makor

hi, please check PM

$50 USD in 0 days
(21 Reviews)
4.9