HOWTO find products that are lacking tier prices

Last modified by Discovery on Fri, June 25, 2010 09:42
Source|Old Revisions  

This is an old revision of the document!


In the B2B environment you may need to setup many tier prices. Keeping track of what products have tiers and what do not can be tricky. Furthermore, it may not be possible to add new tiers through the API, even if updates are easy.

This script enables you to go through all of your configurable products to spot what does not have a tier price set.

In use

You will need to have a user for api setup in Magento (see System menu) with API key. Put the details and the name of your site in the top of this script and run it from the command line with ‘php findtierless.php’ The output will be a list of sku’s and product names.

This simple script can be modified to work on simple products too, you can also modify it to show Magento product id’s instead of sku’s.

The code

// findtierless.php -find products that have no price tiers.

// if store not in /magento change to your directory, e.g. /shop or /store.
$client= new SoapClient('');

// Can be added in Magento-Admin -> Web Services with role set to admin

$sess_id= $client->login('APIUSER', 'APIPASS');

// Get the product list through SOAP
$all_products=$client->call($sess_id, 'product.list');

// Go for configurable parents with no simple children

foreach($all_products as $product)
{ if ($product['type']=="configurable")
  { // $sql = mysql_query('select * from catalog_product_super_link where parent_id='.$product['product_id']);
    $product_details=$client->call($sess_id, '',$product['sku']);
    { $empties++;
      echo $product['sku']."t".$product['name']."n";
    //if (mysql_num_rows($sql)==0)
    //{ $empties++;
     // echo $product['sku']."t".$product['name']."n";
echo "nn".$empties." configurable products lacking tier prices.nn";