cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 adding tier prices via api

SOLVED

Magento 1.9 adding tier prices via api

Hey guys I have written a script to try and add tier pricing to some products but it doesn't seem to be working, I am getting no errors at all screen stays at white screen, but going to backend and checking it hasn't added tier pricing to the products. 

 

My script is:

 

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set("soap.wsdl_cache_enabled", "0");

$proxy = new SoapClient('http://magento/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('apiuser', 'apikey');
 
$row = 1;
 $errors = 0;
$handle = fopen('apiTierAttempt.csv', 'r');
 
while (($data = fgetcsv($handle,',')) !== false) {
    if ($row != 1) {
        $tierPrices = '';
        $sku = $data[0];
 
        $tierPrices[] = array(
            'website'=> $data[1],
            'customer_group'=> $data[2],
            'qty'=> $data[3],
            'price'=> $data[4]
        );
 
        try {
            $proxy->call($sessionId, 'product_tier_price.update', array($sku, $tierPrices));
            var_dump($proxy);
        } catch (Exception $e) {
            $errors = 'Error for SKU ' . $sku . ': ' . $e->getMessage() . " \n";
            echo($errors);
        }
    }
    $row++;
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 1.9 adding tier prices via api

The script works. It was a csv file issue. It didn't like the file, causing it to read it incorrectly. Thus, I just went back into excel on my mac and re-saved it in windows format.

View solution in original post

2 REPLIES 2

Re: Magento 1.9 adding tier prices via api

The script works. It was a csv file issue. It didn't like the file, causing it to read it incorrectly. Thus, I just went back into excel on my mac and re-saved it in windows format.

Re: Magento 1.9 adding tier prices via api

i think you should check out this extension: Tier Prices Extension