Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Trouble adding Tiered Prices using SOAP API
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

I’ve been trying to load price tiers for user groups using the SOAP API and am having little progress. The API successfully loaded the data into the catalog_product_entity_tier_price table but the tiers do not show up in the admin or on the front end.

Some detail on our pricing structure:
A default retail price will display for those who are not logged in or do not belong to a user group. Ths price is loaded as the price for the SKU and is equal to double the tier1 price. We have 5 user groups. User groups 1 and 2 get quantity based pricing. Group1 starts at the lowest of 3 tiers of pricing and gets better discounts depending on quantity. Group2 starts at tier 2 and also gets discounts depending on quantity. Group3 gets a flat rate of tier3 pricing. Group 4 and 5 get their respective price tiers as well. Very complicated to say the least.

Table of price structure:

Group    Qty      Price Tier
1        1        1
1        25       2
1        145      3
2        1        2
2        145      3
3        1        3
4        1        4
5        1        4
0        1        
default price

Example of catalog_product_entity_tier_price table data for a single SKU

value_id      entity_id    all_groups    customer_group_id     qty            value        website_id
4             1            0             2                     1.0000         9.2500       1
5             1            0             2                     25.0000        8.9500       1
6             1            0             2                     145.0000       8.2500       1
7             1            0             3                     1.0000         8.9500       1
8             1            0             3                     145.0000       8.2500       1
9             1            0             4                     1.0000         8.2500       1
10            1            0             5                     1.0000         7.5500       1
11            1            0             6                     1.0000         7.3500       1

Example code to build price tiers array

try{
    $client 
= new SoapClient('http://127.0.0.1/magento/api/?wsdl', array("trace"=>1));
    
$sessionId $client->login('login''apikey');
}catchSoapFault $fault echo $fault->getMessage(); exit(); }

    try{
        $tierPrices 
$client->call($sessionId'product_tier_price.info'$sku);
    
catch( SoapFault $fault echo $fault->getMessage(); }

        
// group 1 pricing
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp1_id,
            
'qty'               => 1,
            
'price'             => $net1_prc
        
);
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp1_id,
            
'qty'               => 25,
            
'price'             => $net2_prc
        
);
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp1_id,
            
'qty'               => 145,
            
'price'             => $net3_prc
        
);
        
// group 2 pricing
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp2_id,
            
'qty'               => 1,
            
'price'             => $net2_prc
        
);
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp2_id,
            
'qty'               => 145,
            
'price'             => $net3_prc
        
);
        
        
// group 3 pricing
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp3_id,
            
'qty'               => 1,
            
'price'             => $net3_prc
        
);
        
        
// group 4
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp4_id,
            
'qty'               => 1,
            
'price'             => $net4_prc
        
);
        
// group 5
        
$tierPrices[] = array(
            
'website'           => $website,
            
'customer_group_id' => $grp5_id,
            
'qty'               => 1,
            
'price'             => $net5_prc
        
);
    
try{
        $client
->call($sessionId'product_tier_price.update', array($sku$tierPrices));
        echo(
"$sku loaded successfully\n");
    
catch( SoapFault $fault {
        
echo $fault->getMessage();
        
var_dump($client->__getLastRequest());
        
var_dump($client->__getLastResponse());
        exit;

    
}

Please help, getting this working is crutial in making Magento a viable solution for our company.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

I found the problem. The API fails to write the tier prices into the catalogindex_price table when you specify a website id or name. It seems to only accept “all” as a parameter. I only have the default “base” website on my instance, but planned to build the ability to specify a website into my loader application. Could this be a bug?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

There has to be a better way to import tiered pricing. SOAP just seems too unpredictable. Several times my product tiers were loaded with the wrong group number - example: group id 5, a static variable, was entered as 0. In addition, the API just duplicates the price tiers if they are the same, instead of updating them.

Of course this is when I’m not getting http header errors!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top