Reputation: 547
I am new in Magento and I am using 1.7.2. I added one product attribute called product type name
. It is a drop down field and values are populated from a different custom table called product_type_name
. I have done successfully so far. Now I want to store the value of product type name into DB Table while adding a product. For that I have added a column product_attrb_type_name
(attribute code) in catalog_product_flat_1
table.
Now while trying to add the product, it is showing the following error
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
Also while trying to edit a product, the values are not set in the product entry form.
How to fix this issue? Could you please help me? Thanks in advance.
Upvotes: 0
Views: 3109
Reputation: 1191
Magento uses EAV table structure, so once you add a attribute they are stored in eav_attribute table with specific entity type (4 for product).
Now when you load a product object, say
$product = Mage::getModel('catalog/product')->load({{entity_id}})
, where entity_id is your product id,
you can use get and set function on this object to set the values of the particular product instance, i.e.
$product->setProductTypeName('someValue'); in your case a a dropdown ,so
$product->setProductTypeName(attributeId);
$product->save();
and get by
$product->getProductTypeName();
You do not have to insert in catalog_product_flat tables, that is Magento way to normalize data into flat tables.
Hope it helps!
Upvotes: 1