Simple function for Configurable product in Magento

  • Status Closed
  • Budget $30 - $250 USD
  • Total Bids 1

Project Description

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

Get free quotes for a project like this
Awarded to:
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online