Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Non Webservices API - Any other APIs? 
 
ShopGuy
Guru
 
Total Posts:  462
Joined:  2008-09-07
 

I am wondering if there is any api other than the webservices API. Making HTTP calls is a little overkill. Is there another API to add / remove products, etc that does not use the webservices API?

 
Magento Community Magento Community
Magento Community
Magento Community
 
vianetz
Guru
 
Avatar
Total Posts:  537
Joined:  2008-04-13
Munich, Germany
 

Why should there be another API? Magento is a web based application, so there there’s a web based API..

 
Magento Community Magento Community
Magento Community
Magento Community
 
ShopGuy
Guru
 
Total Posts:  462
Joined:  2008-09-07
 

All right, after much search I found it. For the benefit of other people:

http://www.magentocommerce.com/wiki/preliminary_magento_api_documentation

//create a new product
try {
  $newProduct 
Mage::getModel('catalog/product')
    ->
setStoreId('default')
    ->
setCategoryIds('4')
    ->
setAttributeSetId(41)
    ->
setPrice(15.49)
    ->
setSku('4you')
    ->
setName('4You T Shirt')
    ->
setManufacturer(20)
    ->
save(); 
    
  echo 
'OK Product ID: '.$newProduct->getId();
}
catch (Mage_Core_Exception $e{
  
echo $e->getMessage();
}
catch (Exception $e{
  
echo $e;
}

Now, for example, if you want to see the code that makes this work, then go to magento/app/code/Mage/Catalog/Model/Product.php and there are a few other files in there, but you can get an idea for what methods are available. Also, attributes automatically become methods: setAttributeName()

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top