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!


Intro

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

<?php
// 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('http://MAGENTOSHOP.co.uk/index.php/api/soap/?wsdl');

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

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

$all_products=$client->call($sess_id, 'product.list');

foreach($all_products as $product)
{ if ($product['type']=="configurable")
  { $product_details=$client->call($sess_id, 'product.info',$product['sku']);
    if(empty($product_details['tier_price']))
    { $empties++;
      echo $product['sku']."\t".$product['name']."\n";
    }
  }
}
echo "\n".$empties." configurable products lacking tier prices.\n";
?>



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs