Skip to content

Instantly share code, notes, and snippets.

@vishy93
Created February 26, 2019 14:38
Show Gist options
  • Save vishy93/902710a47c47f8e14ae50cadc1904b8a to your computer and use it in GitHub Desktop.
Save vishy93/902710a47c47f8e14ae50cadc1904b8a to your computer and use it in GitHub Desktop.
Script to add tiered pricing from an csv file
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$proxy = new SoapClient('http://www.MYSITESURL.co.uk/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('SOAPUSER', 'SOAPPASS');
$row = 1;
$errors = 0;
$handle = fopen('tier.csv', 'r');
while (($data = fgetcsv($handle,0,",")) !== false) {
if ($row != 1) {
$tierPrices = '';
$sku = $data[0];
$tierPrices[] = array(
'website'=> 'all',
'customer_group_id'=> 'all',
'qty'=> '10',
'price'=> $data[1]
);
try {
echo('Adding tiered pricing too: '. $sku . "<br/>");
$proxy->call($sessionId, 'product_tier_price.update', array($sku, $tierPrices));
} catch (Exception $e) {
$errors = 'Error for SKU ' . $sku . ': ' . $e->getMessage() . " <br/>";
echo($errors);
}
}
$row++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment