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);
curl_close($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);
xml_parser_free($p);
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');
$category->setStoreId(0);
$categoryName = $cate;
$rootCategory['name'] = $categoryName;
$rootCategory['path'] = "1/2";
//$rootCategory['display_mode'] = "PRODUCTS";
$rootCategory['is_active'] = 1;
$category->addData($rootCategory);
try
{
$category->save();
$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'];
//print_r($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();
$product->setSku($product_sku);
$product->setName($name);
$product->setDescription($des);
$product->setShortDescription($shortdes);
//-- price section
$product->setPrice($price);
//$product->setSpecialPrice(10);
//----- company address and map
$product->setTypeId('simple');
$product->setAttributeSetId(9); // default
$product->setCategoryIds(array(20)); // need to look these up
$product->setWeight(1.0);
$product->setTaxClassId(2); // taxable goods
$product->setVisibility(3); // search
$product->setStatus(1); // enabled
$productQty = '1';
//$stockData=$product->getStockData();
$stockData['qty']=$productQty;
$stockData['is_in_stock']=1;
$stockData['manage_stock']=1;
$stockData['use_config_manage_stock']=0;
$product->setStockData($stockData);
// adding images to product
$abspath = getcwd();
$path = "./final_images/new/".$final_image;
//print_r($path);
?>
<?php
if (file_exists($path)) {
$product->addImageToMediaGallery($path,array('image','small_image','thumbnail'),false,false);
}
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
$product->save();
/*********** custom option for cart ***********/
$new_product_id=$product->getId();
$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(
array(
'is_delete' => 0,
'title' => '12',
'price_type' => 'fixed',
'price' => '',
'sku' => '',
'sort_order' => 0,
),
array(
'title' => '18',
'price_type' => 'fixed',
'price' => '',
'sku' => '',
'sort_order' => 1,
)),
);
$product->setHasOptions(1);
$option = Mage::getModel('catalog/product_option')
->setProductId($new_product_id)
->setStoreId(1)
->addData($optionData);
$option->save();
$product->addOption($option);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product->save();
/*********** 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.
Best Answer
There are 4 types of users in Magento 2 (see \Magento\Authorization\Model\UserContextInterface), any of them can be used while making requests via web APIs :
Integration can be created at
System > Integration > Add New Integration
, it can be given the same permissions as any Admin user (ACL tree is the same). Web API requests can be made on behalf of both, admin and integration. What differs integration from the admin user is that 3rd party can retrieve web API credentials using OAuth handshake.OAuth handshake allows to integrate with multi-user 3rd party system automatically (when supported by 3rd party):
Callback URL
andIdentity Link URL
(both should be provided by 3rd party system)API
tab of Integration edit pageQuick note about calling multiple services at once, this feature is better known as aggregation APIs and does not have anything in common with Integration user type.