2

Admin can upload the product from the admin dashboard:

  • >> Catalog
  • >> Manage Product
  • >> Add product

I am implementing a custom product upload form in user panel where a user can sign in his account and upload his product and he can sell it.

I am able to generate the product form. However, I am not able to get proper input type in the form.

How can I get the proper input type and which database table is used in product form creation?

1 Answer 1

1

You can do this. First you should create html form to enter and send product data to controller. Required attributes such as name, sku, status, visibility, tax_class, price, description, short-description and other attributes wich is needed to built your catalog logic - all has own input and input type. Use this attributes to figure html form.

Second you should get and validate all data through controller and create new product:

$data=$this->getRequest()->getPost();
//$data validation logic here
$paroduct=Mage::getModel('catalog/product');
//if some Magento entity/collectioan related error appears use next line;
//Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
//there is required attributes
$product->setAttributeSetId($product->getDefaultAttributeSetId())
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
->setSku($data['sku'])
->setName($data['name'])
->setPrice($data['price'])
->setTaxClassId($data['tax_class_id'])
->setVisibility($data['visibility'])
->setCreatedAt(now());

//you can add your extra attributes here
$product->setBrand($data['brand']);
//.....
try{
$product->save();
Mage::getSingleton('customer/session')->addSuccess("Product created successfully!");
}catch(Exception $e){
 Mage::getSingleton('customer/session')->addError($e->getMessage());
}
2
  • @MmageUz.. Thank you very much. I got some idea through your post. I have generated a form dynamically using attribute set. In attribute sets it also has information about the input type like text, dropdown, textarea. However, some fields had boolean and some extra type in it. I am not getting any way about whats that input types are and how to utilize them in a form to generate it dynamically. Otherwise, I need to go through custom hard coded form. :( .. any help....Thank you in advance
    – MagentoBoy
    Commented Jun 21, 2013 at 6:16
  • @MageUz.. Hi , how can i use input type and attributes to make catalog logic?
    – MagentoBoy
    Commented Sep 2, 2013 at 6:15

Your Answer

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

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