I have searched for a week to find the specific solution to my problem maybe one of you can help! It would be very appreciated :)
I have some products with Tier Pricing that I added through the Magento Admin backend manually and it works beautifully. I am able to update those prices programmatically and the results are amazing!
However here is my problem. For products with no current tier prices I can't add them programmatically :( I have far too many products and variations to manually go and giev each product 6 tier prices.
Here is some example code:
If I call var_dump($product->getData('tier_price'))
on an item with one tier.
array(1) {
[0]=>
array(7) {
["price_id"]=>
string(3) "403"
["website_id"]=>
string(1) "0"
["all_groups"]=>
string(1) "0"
["cust_group"]=>
string(2) "12"
["price"]=>
string(7) "84.2400"
["price_qty"]=>
string(6) "1.0000"
["website_price"]=>
string(7) "84.2400"
}
}
I created a variable called $standardTierPrices which is:
$standardTierPrices = array();
I realize it doesn't have ["price_id"]
but how can I add that if it auto increments and starts whenever created? Even with me custom setting unique ['price_id'] it still doesn't work I tested it! I also tried without all_groups and website_price, still no cigar.
>$standardTierPrices[0] = array(
"website_id" => "0",
"all_groups" => "0",
"cust_group" => "8",
"price" => "1950.0000",
"price_qty" => "1.0000",
"website_price" => "1950.0000"
);
Now I call
$product->unsTierPrice()->save()->setTierPrice($standardTierPrices)->save();
If I run $product->getData('tier_prices')
I can see the attribute gets added but it is not updated in the Admin panel
I want the tier prices to show in the admin panel not just the attributes.
Here is a specific picture of what I want and what I get.
https://i.sstatic.net/NWNSc.jpg
TLDR:: I want to programmatically create this for an item -> https://i.sstatic.net/t5QaN.jpg, a tier pricing in the Admin Panel
From a product that starts with no tier pricing.