by

Deep

24 Feb 2015, 07:15 am

about the author

About Deep

Magento Web Development: Upload Product From Front-End To Different Stores

Magento Web Development

Magento, as all we know, is a large and powerful open-source eCommerce platform. It is mainly based on MySQL relational database management system and written in PHP scripting language on Zend framework. It applies the conventions of object-oriented programming and model-view-controller architecture. There are lots of reasons why Magento web development is the best option for an eCommerce website. It gives you a cool product ordering system.

 

Magento web development allows you to edit, create, view, and fulfill orders from the admin interface. It provides built-in SEO functionality, tags, descriptions, very clean URLs, site navigation and clean HTML. It offers a number of extra features like the ability to import huge spreadsheets of product, newsletter, built-in functionality for all major merchant accounts with no limits on the number of product or purchases.

Also Read: Backup Buddy: The Best Backup Plugin For WordPress

Magento has its own extensions marketplace called Magento Connect. On Connect, people can download new extensions to their stores by selecting an extension key and adding it to the Connect Manager in their store. It provides regular updates and constant improvements are what you can expect from the Magento team that consists over 200 people working on the CMS on a daily basis.

Ecommerce Magento Web Development

Magento also provides a feature called Multiple Stores. Multiple Stores functionality allows you to power any number of stores or websites within a single Magento installation. This way you can make your site multilingual too. Sometimes you can face problems regarding uploading products in multi stores. It is quite easy through Magento backend but it sometimes gets very tough from a simple front view. Today I am going to show you how you can add products through a spreadsheet with all its data with product images for multiple stores using Magento development.

Codes:

Sample code:


$insertId=Mage::getSingleton('core/resource')->getConnection('core_read')->fetchOne('SELECT last_insert_id()'); // last inserted product id stored here.

$product = Mage::getModel('catalog/product')->load($insertId);

$product->setStoreId(STORE_ID)->setName('new_name')->save();//storing data in this way

Full code:


foreach( $xlsx->rows() as $k => $r) {

if ($k == 0) continue;//Ingnoring first column of excel file

try{

//grabbing categories for en

$key=array_search($r[55],$cat_arr);

$key2=array_search($r[56],$cat_arr);

$key3=array_search($r[57],$cat_arr);

 

//grabbing categories for de

$keyde=array_search($r[52],$cat_arr);

$key2de=array_search($r[53],$cat_arr);

$key3de=array_search($r[54],$cat_arr);

 

//grabbing categories for nl

$keynl=array_search($r[49],$cat_arr);

$key2nl=array_search($r[50],$cat_arr);

$key3nl=array_search($r[51],$cat_arr);

 

//Set the path of image folder

$imgpath_total=Mage::getBaseDir()."\media\proimg/12001.jpg";//.$r[59]

 

 

$newProduct = new Mage_Catalog_Model_Product();

$newProduct->setAttributeSetId(4)

->setTypeId('simple')

->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)

->setTaxClassId(2)

->setCreatedAt(strtotime('now'))

->setSku($r[39])

->setWeight($r[40])

->setBrand($r[5])

->setTags($r[58])

->setAlc_percentage($r[42])

->setWeight('10')

->setEan($r[37])

->setStatus(1)

->setPrice($r[22])

->setWebsiteIds(array(1))

->setStockData(array('is_in_stock' => 1, 'qty' => 99999 ))

->setSetupFee(522)

//->addImageToMediaGallery($imgpath_total,array('image','small_image','thumbnail'),false,false)

->setsetupCost(100)

->setName($r[17])

->setTitle_long($r[18])

->setGoogle($r[64])

->setDescription($r[20])

->setShort_description($r[19])

->setCategoryIds(array(2,$key,$key2,$key3));

 

$newProduct->save();

$insertId= Mage::getSingleton('core/resource')->getConnection('core_read')->fetchOne('SELECT last_insert_id()');

 

$product = Mage::getModel('catalog/product')->load($insertId);

 

#################Dutch###############

$product->setStoreId(7)

->setName($r[12])

->setTitle_long($r[13])

->setGoogle($r[63])

->setDescription($r[15])

->setShort_description($r[14])

 

->save();

 

################End Dutch#############

 

#############Netherland ################

$product->setStoreId(8)

->setName($r[7])

->setTitle_long($r[8])

->setGoogle($r[62])

->setDescription($r[10])

->setShort_description($r[9])

->save();

#############End Netherland##########

 

 

#####save your product###################

 

}catch(Exception $e){

$result['status'] = 3;

$result['message'] = 'There is an ERROR happened! NOT ALL products are created! Error:'.$e->getMessage();

echo json_encode($result);

return;

}

exit;

}

 

If you go through the code you will find that all data are fetching from a spreadsheet with the code “$xlsx->rows()”. And data got to three different stores: 1)English (store id 1) 2)Dutch (store id 7) 3)Dutch (store id 8). Hope you like it. Thanks.

by

Deep

24 Feb 2015, 07:15 am

about the author

About Deep
Comment with Facebook

trending

Featured Posts

Editors Choice

Reviews