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– ProxiBlue2013年10月11日 12:15:59 +00:00Commented 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?Jim– Jim2013年10月12日 04:53:28 +00:00Commented Oct 12, 2013 at 4:53
-
Look at custom options in the product config. This may work for you.ProxiBlue– ProxiBlue2013年10月12日 10:27:37 +00:00Commented Oct 12, 2013 at 10:27
-
ya that will work. but i added many products is there anyway to add color?Jim– Jim2013年10月15日 12:02:20 +00:00Commented 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?)ProxiBlue– ProxiBlue2013年10月15日 15:29:18 +00:00Commented Oct 15, 2013 at 15:29
1 Answer 1
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– Jim2013年10月17日 11:18:19 +00:00Commented Oct 17, 2013 at 11:18
-
NP, can do so tomorrow.ProxiBlue– ProxiBlue2013年10月17日 12:38:14 +00:00Commented 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/304637ProxiBlue– ProxiBlue2013年10月18日 04:04:54 +00:00Commented Oct 18, 2013 at 4:04
Explore related questions
See similar questions with these tags.