1

For: Simple Product

As you can see the image i displayed the color attribute in dropdown in view page. now the customer can select the color. after they clicking buy now i need to save the color in sales grid....

attribute for color not saved in database

i displayed the attribute in dropdown in view page

  • Why not use a configurable product? This has the functionality built in, and is meant for this. You are attempting to re-create already existing functionality. – ProxiBlue Oct 11 '13 at 12:15
  • when i strats i am not aware of configurable product. on top of it i added 1000 products. so changing now is not possible. is there do any way for simple product? – Jim Oct 12 '13 at 4:53
  • Look at custom options in the product config. This may work for you. – ProxiBlue Oct 12 '13 at 10:27
  • ya that will work. but i added many products is there anyway to add color? – Jim Oct 15 '13 at 12:02
  • You want thus to add the same custom option to all products? Would this custom option contain the same values ( tthus the same list of colors?) – ProxiBlue Oct 15 '13 at 15:29
2

Ok, from your comments, I suggest a bit of googling for solutions on how to add Custom Options to existing products programmatically.

A fairly good example is here :

http://www.magegurus.com/magento-how-to-add-custom-options-programmatically/

(since we don't want a link fest, I duplicate this guide here. Note this is not my work work)

$option = array(
        'title' => 'Your custom option title',
        'type' => 'radio', // could be drop_down ,checkbox , multiple
        'is_require' => 1,
        'sort_order' => 0,
        'values' => getOptions()
        );

function getOptions(){
  return array(
   array(
        'title' => 'Option Value 1',
        'price' =>100,
        'price_type' => 'fixed',
        'sku' => 'any sku for 1',
        'sort_order' => '1'
        ),
    array(
        'title' => 'Option Value 2',
        'price' =>100,
        'price_type' => 'fixed',
        'sku' => 'any sku for 2',
        'sort_order' => '1'
        ),
      array(
        'title' => 'Option Value 3',
        'price' =>100,
        'price_type' => 'fixed',
        'sku' => 'any sku for 3',
        'sort_order' => '1'
        )
  );
}

//Suppose we are creating a new product.
$product = Mage::getModel('catalog/product');
$product->setProductOptions(array($option));
$product->setCanSaveCustomOptions(true);

//Or if we are adding the options to a already created product.
$product = Mage::getModel('catalog/product')->load($id);
$product->setProductOptions(array($option));
$product->setCanSaveCustomOptions(true);

//Do not forget to save the product
$product->save();

Since you need to add different options to the products, you would need to create a csv file, and map options to product id's (or skus) in the csv.

Turn the csv into an array of key=>values, and the getOptions routine above could be used to pull in the options for a product sku (where the sku = the key of the array) Naturally if each value will have diffrent price settings etc, the csv would get a bit more complicated.

This should get you going into the right direction. If you don't know how to do the above (no idea if you are a coder) let me know....and I can help further.

  • Sorry i am new to magento i don't know where to add this code can you guide me? thanks................ – Jim Oct 17 '13 at 11:18
  • NP, can do so tomorrow. – ProxiBlue Oct 17 '13 at 12:38
  • Hi, thought I'd have time, but a new client/project just got thrown at me. I suggest you look at Magmi (no coding required) (sourceforge.net/projects/magmi) as a means to import/add the custom value into your products. see also this discussion which deals specifically with this situation: magentocommerce.com/boards/viewthread/304637 – ProxiBlue Oct 18 '13 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.