Customer creation
I assume you're using the standard customerCustomerCreate() SOAP v2 Method.
This method is referenced in app/code/core/Mage/Customer/etc/wsdl.xml
(grep for: "customerCustomerCreate").
The method create
is defined in Model/Customer/Api.php
where you can see that the customer/customer
Model is called:
class Mage_Customer_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
{
....
/**
* Create new customer
*
* @param array $customerData
* @return int
*/
public function create($customerData)
{
$customerData = $this->_prepareData($customerData);
try {
$customer = Mage::getModel('customer/customer')
->setData($customerData)
->save();
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return $customer->getId();
}
...
}
The Mage_Customer_Model_Customer_Api_V2
class extends Mage_Customer_Model_Customer_Api
.
So you'll need a bit of effort just to change it for the created customers via SOAP.
The password length is hardcoded in Mage_Customer_Model_Customer_Attribute_Backend_Password
(see: $len = Mage::helper('core/string')->strlen($password);
and if ($len < 6)
).
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 many ext available for tax rates via API on Magento Connect
http://www.magentocommerce.com/magento-connect/sales-tax-extension-for-avalara-s-avatax.html
You can set table rates in Magento but there is not "Public" API for taxes available.