I'm a web developer of a company that produce ERP software. I would like to integrate the ERP software with Magento ecommerce solution with automatic synchronization function through API call. I've read a lot of information about SOAP Api call but i didn't understand if that will be possible.

I read something about "createacategory" SOAP method, but nothing about attributes.

I need to create a function that can be usefull for every single client-company.

That's why i need to put all the necessary information about product through auto import method.

How can i do that? it's possible? there is a method for importing attributes?


As i understand your query, here is the method to get the api data, into xml format first.

$xml contain xml response you have made to get the data from api.

$soap_do = curl_init();
            curl_setopt($soap_do, CURLOPT_URL,            $url );
            curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
            curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($soap_do, CURLOPT_POST,           true );
            curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($soap_do, CURLOPT_POSTFIELDS,    $xml);

            $result = curl_exec($soap_do);

            //echo $result;
            //echo $result_array = json_encode($result);
            //echo   $description = $result->extendeddescription;

$p = xml_parser_create();
xml_parse_into_struct($p, $result, $vals, $index);

After you can break the xml into array and get the value. here $vals contains the valid array of xml comes data. If you want to import the product as find into xml array you need to run new product making script with valid input param comes form api.

The Below code, you can used to add or update new category

$category = Mage::getModel('catalog/category');
                                                  $categoryName = $cate;
                                                  $rootCategory['name'] = $categoryName;
                                                  $rootCategory['path'] = "1/2"; 
                                                  //$rootCategory['display_mode'] = "PRODUCTS";
                                                  $rootCategory['is_active'] = 1;

                                                    $CategoryId = $category->getId();
                                                  catch (Exception $e)
                                                    echo "categories not found";

And for product adding you need to follow the below script with valid input params

$obj = Mage::getModel('catalog/product');
$_product = $obj->load($productid); // Enter your Product Id in $product_id
// get Product's name
$name = $_product->getName();
//get product's short description
$shortdes = $_product->getShortDescription();
//get Product's Long Description
$des = $_product->getDescription();
//get Product's Regular Price
//echo $_product->getPrice();
//get Product's Special price
//echo $_product->getSpecialPrice();
//get Product's Url
//echo $_product->getProductUrl();
//get Product's image Url
//echo $_product->getImageUrl();
//echo "<pre>";print_r($_GET);exit;

/*********Getting values*********/

$optionval1 = $_GET['optionval1'];
$optionval2 = $_GET['optionval2'];
$optionval3 = $_GET['optionval3'];
$optionval4 = $_GET['optionval4'];
$image = $_GET['image'];
$image_parts = explode('/',$image);
$count = count($image_parts);
$final_image = $image_parts[$count-1];
//echo "<pre>";print_r($image_parts[$count-1]);exit;
$price = $_GET['price'];
$product = Mage::getModel('catalog/product');
$product_sku = time();
//-- price section

//----- company address and map
$product->setAttributeSetId(9); // default
$product->setCategoryIds(array(20)); // need to look these up

$product->setTaxClassId(2); // taxable goods
$product->setVisibility(3); // search
$product->setStatus(1); // enabled
$productQty = '1';


// adding images to product
$abspath = getcwd();

$path = "./final_images/new/".$final_image;

if (file_exists($path)) {

/*********** custom option for cart ***********/
                                        $product = Mage::getModel('catalog/product')->load($new_product_id);
                                        $optionData = array(
                                                'is_require'        => false,
                                                'title'             => 'Select Font',
                                                'type'              => 'drop_down',
                                                'sort_order'        => 0,
                                                'values'            => array(
                                                        'is_delete'     => 0,
                                                        'title'         => '12',
                                                        'price_type'    => 'fixed',
                                                        'price'         => '',
                                                        'sku'           => '',
                                                        'sort_order'        => 0,
                                                        'title'         => '18',
                                                        'price_type'    => 'fixed',
                                                        'price'         => '',
                                                        'sku'           => '',
                                                        'sort_order'        => 1,
                                        $option = Mage::getModel('catalog/product_option')
/*********** custom option for cart end***********/
$productid = $product->getId();
$result['product'] = $productid;
echo $result['product'];

Hope this will help you, or make sense what you should need to do.

  • In this way I should be able to import attributes ( like colour, price, size and other attribute set ), categories (like t.shirt, dress,man, woman, etc.), and also product into magento? – laura Jun 19 '14 at 12:08
  • Please specified me that you got the array of all products, attributes, category . if yes i am going to update my Answer. You just need to put the valid array data into param and you would be able to add category, product etc. – Ami Kamboj Jun 19 '14 at 12:10
  • @user3686751 i have updated my answer, hope this will help you. If you find any trouble please specified me your array data. howz it comes may update you-- Thankyou. – Ami Kamboj Jun 19 '14 at 12:14
  • thanks thts help me a lot.. but with this method I'm able to import category and product. But, I didn't understand Attribute. is this section ? /*********Getting values*********/ $optionval1 = $_GET['optionval1']; $optionval2 = $_GET['optionval2']; $optionval3 = $_GET['optionval3']; $optionval4 = $_GET['optionval4']; every optional value is an extra attribute? can I also create the attribute set? – laura Jun 19 '14 at 12:50
  • Please verify the Answer, and keep on stack exchange hope it will help you. – Ami Kamboj Jun 19 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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