Example #1
0
function downloadFile($cacheFile)
{
    file_put_contents($cacheFile, '');
    $options = array('exceptions' => true, 'trace' => true, 'encoding' => 'utf-8');
    $clientScript = new SoapClient(getWSDL(), $options);
    $session = $clientScript->login('B2BUser', 'B2BUser');
    $array = array();
    // 	$array[] = array('key'=>'created_at','value'=>array('key' =>'from','value' => trim('0001-01-01')));
    $array[] = array('key' => 'created_at', 'value' => array('key' => 'from', 'value' => trim('2015-08-03')));
    $params = array('complex_filter' => $array);
    $products = $clientScript->catalogProductList($session, $params);
    $attributeSets = array();
    $attributeSetsMage = $clientScript->catalogProductAttributeSetList($session);
    foreach ($attributeSetsMage as $attributeSetMage) {
        $attributeSets[$attributeSetMage->set_id] = trim($attributeSetMage->name);
    }
    echo "Attribute Sets:\n" . print_r($attributeSets, true);
    echo "\n";
    $manufacturers = array();
    $manufacturersMage = $clientScript->catalogProductAttributeOptions($session, 'manufacturer');
    foreach ($manufacturersMage as $manufacturerMage) {
        if (trim($manufacturerMage->value) !== '') {
            $manufacturers[$manufacturerMage->value] = trim($manufacturerMage->label);
        }
    }
    echo "Manufacturers:\n" . print_r($manufacturers, true);
    echo "\n";
    echo "Got " . count($products) . " products\n";
    foreach ($products as $index => $product) {
        try {
            echo "No.: " . $index . ", SKU:" . $product->sku . "\n";
            $pro = $clientScript->catalogProductInfo($session, trim($product->sku), null, getInfoAttributes());
            $proArray = getProductArray($clientScript, $session, $product, $pro, $attributeSets, $manufacturers);
            echo "\t JSON: " . json_encode($proArray) . "\n";
            if (count($proArray) > 0) {
                file_put_contents($cacheFile, json_encode($proArray) . "\n", FILE_APPEND);
            }
        } catch (SoapFault $e) {
            var_dump($e);
        }
    }
    echo "File :" . $cacheFile . ' downloaded.';
}
Example #2
0
//error_reporting ( - 1 );
error_reporting(1);
umask(0);
Mage::app("default");
$proxy = new SoapClient('http://52.11.138.2/index.php/api/v2_soap/?wsdl');
$sessionId = $proxy->login('testapi', 'justdoit');
$cartId = $proxy->shoppingCartCreate($sessionId, 1);
// load the customer list and select the first customer from the list
$complexFilter = array('complex_filter' => array(array('key' => 'email', 'value' => array('key' => 'eq', 'value' => '*****@*****.**'))));
$customerList = $proxy->customerCustomerList($sessionId, $complexFilter);
$customer = (array) $customerList[0];
$customer['mode'] = 'customer';
$proxy->shoppingCartCustomerSet($sessionId, $cartId, $customer);
// load the product list and select the first product from the list
$complexFilter = array('complex_filter' => array(array('key' => 'sku', 'value' => array('key' => 'eq', 'value' => 'testMritun2'))));
$productList = $proxy->catalogProductList($sessionId, $complexFilter);
$product = (array) $productList[0];
$product['qty'] = 1;
$product['erp_price'] = 100;
$product['erp_discount'] = 12;
$proxy->shoppingCartProductAdd($sessionId, $cartId, array($product));
$address = array(array('mode' => 'shipping', 'firstname' => $customer['firstname'], 'lastname' => $customer['lastname'], 'street' => 'Domlur 2nd layout', 'city' => 'Bangalore', 'region' => 'Karnataka', 'telephone' => '9691588020', 'postcode' => '560071', 'country_id' => 'IN', 'is_default_shipping' => 0, 'is_default_billing' => 0), array('mode' => 'billing', 'firstname' => $customer['firstname'], 'lastname' => $customer['lastname'], 'street' => 'Domlur 2nd layout', 'city' => 'Bangalore', 'region' => 'Karnataka', 'telephone' => '9691588020', 'postcode' => '560071', 'country_id' => 'IN', 'is_default_shipping' => 0, 'is_default_billing' => 0));
// add customer address
$proxy->shoppingCartCustomerAddresses($sessionId, $cartId, $address);
// add shipping method
$proxy->shoppingCartShippingMethod($sessionId, $cartId, 'flatrate_flatrate');
$paymentMethod = array('po_number' => null, 'method' => 'checkmo', 'cc_cid' => null, 'cc_owner' => null, 'cc_number' => null, 'cc_type' => null, 'cc_exp_year' => null, 'cc_exp_month' => null);
// add payment method
$proxy->shoppingCartPaymentMethod($sessionId, $cartId, $paymentMethod);
// place the order
$orderId = $proxy->shoppingCartOrder($sessionId, $cartId, null, null, '151020C-811014');