magento - Add all my EAV attributes to a product -
so going thru alan storm's magento tutorials , completed page eav attributes. http://alanstorm.com/magento_advanced_orm_entity_attribute_value_part_1
it worked flawlessy, have couple questions. have xml feed trying read products , storing in db. while works, , added new table created, when in admin under manage-->products, there no products listed.
i noticed in admin when go catalog-->manage attributes, don't see new eav attributes. explanation, , looking @ new db tables, see actual product data & attribute meta data being stored; in newly created tables.
but to:
- see these new products saving db in manage products in admin
- make sure new eavs added (based on xml field names) associated these items when placed in main admin product view
i followed code exactly, changed names based on experiment:
foreach ($xml $c) { $car = mage::getmodel('vehicleimport/eavvehicle'); ... ... ... $car->save(); }
if use magento products manager, should stick magento core functionality. there no products in catalog > manage products
because not use mage_catalog module , entities store products.
instead using custom module. not correct way store catalog.
it seems want use custom attributes on products. that's fine , correct. need add them catalog_product
entity, not you're custom eavvehicle
.
to add new product attribute go admin panel catalog > manage attributes
, create new one. there way create them dynamically. use mage_catalog_model_resource_setup
object, e.g.:
$catalogsetup = mage::getresourcemodel('catalog/setup','default_setup'); $catalogsetup->addattribute('catalog_product', 'attribute_name', array $attributedefinition);
or can use module define setup , use upgrade scripts add new attributes when needed.
you can define attribute sets group attributes. allows put necessary attributes on products.
you use mage::getmodel('catalog/product')
add products. loop like:
foreach ($xml $c) { $car = mage::getmodel('catalog/product'); ... ... ... $car->save(); }
if you're using multiple store views (perhaps language versions) can set different language values same product. save them proper store need set correct store view, e.g.:
$car = mage::getmodel('catalog/product'); $car->setstoreid(mage::app()->getstore('french')->getid()); $car->setname('french name of car'); $car->save();
if not use multiple store views, safe set admin
store id on product before save.
mandatory fields/attributes creating new product in magento:
- attribute_set_id
- type_id (i.e. simple, configurable, grouped, etc.)
- website_ids (as array)
- is_active
- status (not sure if it's mandatory)
- visibility
- all attributes grouped in attribute set set required (i.e. sku, name, price, tax_class_id, etc.)
Comments
Post a Comment