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

Tier Pricing API - update multiple tiers at once
 
vernlib
Jr. Member
 
Total Posts:  15
Joined:  2009-01-19
 

What I’d like to figure out is how to add and update multiple tiers for a single product…
i.e. - 10 for $25.00, 25 for $15.00, etc.

I’ve successfully gotten the Tier Pricing API to add and update one tier for one product using the following code:

$proxy = new SoapClient('http://path/index.php/api/?wsdl');
$sessionId $proxy->login('user''api_key');
  
// Add new
$tierPrices[] = array(
    
'website' => 'all',
    
'customer_group_id' => 'all',
    
'qty' => 10,
    
'price' => 25.00
); 
 
// Update tier prices
$proxy->call($sessionId'product_tier_price.update', array('sku'$tierPrices));

Any feedback would be greatly appreciated!

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ckosny
Guru
 
Total Posts:  349
Joined:  2009-02-28
Luxembourg
 

Simply add another entry to the array $tierPrices:

$tierPrices = array();
//first tierprice
$tierPrices[] = array(
    
'website' => 'all',
    
'customer_group_id' => 'all',
    
'qty' => 10,
    
'price' => 25.00
); 
//second tier price
$tierPrices[] = array(
    
'website' => 'all',
    
'customer_group_id' => 'all',
    
'qty' => 25,
    
'price' => 15.00
); 

//third tier price
...
 
// save the tier prices
$proxy->call($sessionId'product_tier_price.update', array('sku'$tierPrices));

Good luck

Claudia

 
Magento Community Magento Community
Magento Community
Magento Community
 
vernlib
Jr. Member
 
Total Posts:  15
Joined:  2009-01-19
 

Thanks Claudia for the fast response, I’ll give it a go today and hopefully all will implement smoothly! - Robyn

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

I can’t get this to work when trying to specify a tier for a specific group. I have used both the group code ("col1") and the group id. The groups exist, and I’ve verified the id’s in the admin as well as via the database but I repeatedly get this error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento/catalogindex_minimal_price`, CONSTRAINT `FK_CATALOGINDEX_MINIMAL_PRICE_CUSTOMER_GROUP` FOREIGN KEY (`customer_group_id`) REFERENCES `customer_group` (`customer_group_id`) ON DELETE CA)string(1228) “
df34f114378ab3e86acf7be101e45d1dproduct_tier_price.update505-036-swebsitebasecustomer_group_id8qty1price8.10

string(566) “
1SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento/catalogindex_minimal_price`, CONSTRAINT `FK_CATALOGINDEX_MINIMAL_PRICE_CUSTOMER_GROUP` FOREIGN KEY (`customer_group_id`) REFERENCES `customer_group` (`customer_group_id`) ON DELETE CA)

the tierPrices array would be something like this:

$tierPrices[] = array(
            
'website'           => 'base',
            
'customer_group_id' => 8,
            
'qty'               => 1,
            
'price'             => 8.10
        
);

Pulling my hair out here! Any ideas?

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

I seem to have found a reason for the errors mentioned above. I have opened a thread here: http://www.magentocommerce.com/boards/viewthread/45870/

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