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

David Manners
27.3k9 gold badges78 silver badges220 bronze badges
asked Oct 11, 2013 at 11:03
6
  • 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. Commented Oct 11, 2013 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? Commented Oct 12, 2013 at 4:53
  • Look at custom options in the product config. This may work for you. Commented Oct 12, 2013 at 10:27
  • ya that will work. but i added many products is there anyway to add color? Commented Oct 15, 2013 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?) Commented Oct 15, 2013 at 15:29

1 Answer 1

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.

answered Oct 17, 2013 at 8:38
3
  • Sorry i am new to magento i don't know where to add this code can you guide me? thanks................ Commented Oct 17, 2013 at 11:18
  • NP, can do so tomorrow. Commented Oct 17, 2013 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 Commented Oct 18, 2013 at 4:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.