How to Update Group Price Programmatically Without Product Object Save
To save group price for the products, the following works for me.
$product->setData('group_price', $group_pricing_data);
$product->save();
However, it takes a while for mass updating products. The faster way to save only attributes via saveAttribute() does not seem to work on group price.
$product->setData('group_price', $group_pricing_data);
$product->getResource()->saveAttribute($product, 'group_price');
Is it because group_price is not EAV like the other attributes, and if so, is there any other way to just save only group pricing?
group-price
add a comment |
To save group price for the products, the following works for me.
$product->setData('group_price', $group_pricing_data);
$product->save();
However, it takes a while for mass updating products. The faster way to save only attributes via saveAttribute() does not seem to work on group price.
$product->setData('group_price', $group_pricing_data);
$product->getResource()->saveAttribute($product, 'group_price');
Is it because group_price is not EAV like the other attributes, and if so, is there any other way to just save only group pricing?
group-price
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30
add a comment |
To save group price for the products, the following works for me.
$product->setData('group_price', $group_pricing_data);
$product->save();
However, it takes a while for mass updating products. The faster way to save only attributes via saveAttribute() does not seem to work on group price.
$product->setData('group_price', $group_pricing_data);
$product->getResource()->saveAttribute($product, 'group_price');
Is it because group_price is not EAV like the other attributes, and if so, is there any other way to just save only group pricing?
group-price
To save group price for the products, the following works for me.
$product->setData('group_price', $group_pricing_data);
$product->save();
However, it takes a while for mass updating products. The faster way to save only attributes via saveAttribute() does not seem to work on group price.
$product->setData('group_price', $group_pricing_data);
$product->getResource()->saveAttribute($product, 'group_price');
Is it because group_price is not EAV like the other attributes, and if so, is there any other way to just save only group pricing?
group-price
group-price
edited Mar 23 '15 at 14:17
musicliftsme
5,34252567
5,34252567
asked Mar 23 '15 at 9:22
zhenmingzhenming
12815
12815
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30
add a comment |
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30
add a comment |
3 Answers
3
active
oldest
votes
As far as I know, you can't simply update group price data using saveAttribute
because it has a custom backend model, catalog/product_attribute_backend_groupprice
.
When you load and save a product object, group price's custom resource mode does the work to load and save the data accordingly. If you look at Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
, you will see the methods Magento uses to load and save group price data.
Specifically, savePriceData
shows how to save the data properly. If you want a fast group price update, you can mimic what's done here. Check how $data
looks like, and you have a good place to start.
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
add a comment |
You can speed up saving group_price attribute like this:
$prices = $product->getData('group_price');
above code return array, next step is to modify this array and last inject as parameter to below:
$product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price')
->getBackend()
->afterSave($product);
5k products 45 ~ 60 sec on docker local environment.
Happy coding,
Adam
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
add a comment |
try to: var_dump($product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price'));
and post here
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f61640%2fhow-to-update-group-price-programmatically-without-product-object-save%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
As far as I know, you can't simply update group price data using saveAttribute
because it has a custom backend model, catalog/product_attribute_backend_groupprice
.
When you load and save a product object, group price's custom resource mode does the work to load and save the data accordingly. If you look at Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
, you will see the methods Magento uses to load and save group price data.
Specifically, savePriceData
shows how to save the data properly. If you want a fast group price update, you can mimic what's done here. Check how $data
looks like, and you have a good place to start.
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
add a comment |
As far as I know, you can't simply update group price data using saveAttribute
because it has a custom backend model, catalog/product_attribute_backend_groupprice
.
When you load and save a product object, group price's custom resource mode does the work to load and save the data accordingly. If you look at Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
, you will see the methods Magento uses to load and save group price data.
Specifically, savePriceData
shows how to save the data properly. If you want a fast group price update, you can mimic what's done here. Check how $data
looks like, and you have a good place to start.
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
add a comment |
As far as I know, you can't simply update group price data using saveAttribute
because it has a custom backend model, catalog/product_attribute_backend_groupprice
.
When you load and save a product object, group price's custom resource mode does the work to load and save the data accordingly. If you look at Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
, you will see the methods Magento uses to load and save group price data.
Specifically, savePriceData
shows how to save the data properly. If you want a fast group price update, you can mimic what's done here. Check how $data
looks like, and you have a good place to start.
As far as I know, you can't simply update group price data using saveAttribute
because it has a custom backend model, catalog/product_attribute_backend_groupprice
.
When you load and save a product object, group price's custom resource mode does the work to load and save the data accordingly. If you look at Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
, you will see the methods Magento uses to load and save group price data.
Specifically, savePriceData
shows how to save the data properly. If you want a fast group price update, you can mimic what's done here. Check how $data
looks like, and you have a good place to start.
answered Mar 23 '15 at 14:17
musicliftsmemusicliftsme
5,34252567
5,34252567
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
add a comment |
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
can you show an example with the above code? I can't get it to work
– Robin
Sep 16 '15 at 13:21
add a comment |
You can speed up saving group_price attribute like this:
$prices = $product->getData('group_price');
above code return array, next step is to modify this array and last inject as parameter to below:
$product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price')
->getBackend()
->afterSave($product);
5k products 45 ~ 60 sec on docker local environment.
Happy coding,
Adam
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
add a comment |
You can speed up saving group_price attribute like this:
$prices = $product->getData('group_price');
above code return array, next step is to modify this array and last inject as parameter to below:
$product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price')
->getBackend()
->afterSave($product);
5k products 45 ~ 60 sec on docker local environment.
Happy coding,
Adam
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
add a comment |
You can speed up saving group_price attribute like this:
$prices = $product->getData('group_price');
above code return array, next step is to modify this array and last inject as parameter to below:
$product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price')
->getBackend()
->afterSave($product);
5k products 45 ~ 60 sec on docker local environment.
Happy coding,
Adam
You can speed up saving group_price attribute like this:
$prices = $product->getData('group_price');
above code return array, next step is to modify this array and last inject as parameter to below:
$product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price')
->getBackend()
->afterSave($product);
5k products 45 ~ 60 sec on docker local environment.
Happy coding,
Adam
answered Feb 6 '18 at 12:47
Adam GierońAdam Gieroń
9111
9111
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
add a comment |
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
I cannot get this to work have you any ideas? "Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBackend() on boolean "
– harri
Jan 29 at 14:28
add a comment |
try to: var_dump($product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price'));
and post here
add a comment |
try to: var_dump($product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price'));
and post here
add a comment |
try to: var_dump($product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price'));
and post here
try to: var_dump($product->setGroupPrice($prices)
->getResource()
->getAttribute('group_price'));
and post here
answered 8 mins ago
Adam GierońAdam Gieroń
9111
9111
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f61640%2fhow-to-update-group-price-programmatically-without-product-object-save%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
did you get this to work @zhenming ?
– Robin
Sep 17 '15 at 5:30