Prevent the quantity of inventory in the backend products is negative
I'm using Magento 1.7.0.2 and Magento 1.9.1.0.
As we know, by default, Qty Inventory at the backend (Admin - Catalog - Manage Products - Edit - General - Inventory - Qty) may contain a negative value, such as -1.
How to prevent the quantity of inventory in the backend products is negative?
magento-1 stock inventory
bumped to the homepage by Community♦ 4 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm using Magento 1.7.0.2 and Magento 1.9.1.0.
As we know, by default, Qty Inventory at the backend (Admin - Catalog - Manage Products - Edit - General - Inventory - Qty) may contain a negative value, such as -1.
How to prevent the quantity of inventory in the backend products is negative?
magento-1 stock inventory
bumped to the homepage by Community♦ 4 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm using Magento 1.7.0.2 and Magento 1.9.1.0.
As we know, by default, Qty Inventory at the backend (Admin - Catalog - Manage Products - Edit - General - Inventory - Qty) may contain a negative value, such as -1.
How to prevent the quantity of inventory in the backend products is negative?
magento-1 stock inventory
I'm using Magento 1.7.0.2 and Magento 1.9.1.0.
As we know, by default, Qty Inventory at the backend (Admin - Catalog - Manage Products - Edit - General - Inventory - Qty) may contain a negative value, such as -1.
How to prevent the quantity of inventory in the backend products is negative?
magento-1 stock inventory
magento-1 stock inventory
edited Oct 31 '17 at 15:32
Teja Bhagavan Kollepara
2,94841847
2,94841847
asked Jan 26 '16 at 6:47
Andhi IrawanAndhi Irawan
3711720
3711720
bumped to the homepage by Community♦ 4 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 4 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You could create a custom module and an event observer hooked to the cataloginventory_stock_item_save_before
event then you can validate if the qty will be saved as negative and perform some action.
Configuration:
Vendor/Module/etc/config.xml
<global>
...
<events>
<cataloginventory_stock_item_save_before>
<observers>
<vendor_module_stock_item_save_before>
<class>vemdor_module/observer</class>
<method>stockItemSaveBefore</method>
</vendor_module_stock_item_save_before>
</observers>
</cataloginventory_stock_item_save_before>
</events>
</global>
...
Observer:
Vendor/Module/Model/Observer.php
class Vendor_Module_Model_Observer
{
public function stockItemSaveBefore(Varien_Event_Observer $observer)
{
$item = $observer->getEvent()->getItem();
// Perform some action ...
}
}
I don't know what do you want to do with that information. You may want to send an email, save a log or just keep the qty in 0, regardless the action you'll take this is the way to do it.
add a comment |
I have seen constellations where qty is negative / < zero in a very small amount of client systems that we did not create from the scratch. The problem is, that the products with negative qty are "in stock/available" and can be bought by shop customers.
Instead of wasting computation time i would add a trigger:
delimiter //
CREATE TRIGGER negative_stock_to_zero BEFORE UPDATE ON cataloginventory_stock_item
FOR EACH ROW
BEGIN
IF NEW.qty < 0 THEN
NEW.qty = 0;
END IF;
END;//
delimiter;
Of course you could also check if backordering is enabled/disabled in the IF-Clause - but thats up to you.
add a comment |
In the admin console under System -> Configuration
Under Catalog -> Inventory
You should see a setting in the Product Stock Options called Backorders. Set this to No Backorders.
Additionally set the "Qty for Item's Status to Become Out of Stock" setting to 0.
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%2f98942%2fprevent-the-quantity-of-inventory-in-the-backend-products-is-negative%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
You could create a custom module and an event observer hooked to the cataloginventory_stock_item_save_before
event then you can validate if the qty will be saved as negative and perform some action.
Configuration:
Vendor/Module/etc/config.xml
<global>
...
<events>
<cataloginventory_stock_item_save_before>
<observers>
<vendor_module_stock_item_save_before>
<class>vemdor_module/observer</class>
<method>stockItemSaveBefore</method>
</vendor_module_stock_item_save_before>
</observers>
</cataloginventory_stock_item_save_before>
</events>
</global>
...
Observer:
Vendor/Module/Model/Observer.php
class Vendor_Module_Model_Observer
{
public function stockItemSaveBefore(Varien_Event_Observer $observer)
{
$item = $observer->getEvent()->getItem();
// Perform some action ...
}
}
I don't know what do you want to do with that information. You may want to send an email, save a log or just keep the qty in 0, regardless the action you'll take this is the way to do it.
add a comment |
You could create a custom module and an event observer hooked to the cataloginventory_stock_item_save_before
event then you can validate if the qty will be saved as negative and perform some action.
Configuration:
Vendor/Module/etc/config.xml
<global>
...
<events>
<cataloginventory_stock_item_save_before>
<observers>
<vendor_module_stock_item_save_before>
<class>vemdor_module/observer</class>
<method>stockItemSaveBefore</method>
</vendor_module_stock_item_save_before>
</observers>
</cataloginventory_stock_item_save_before>
</events>
</global>
...
Observer:
Vendor/Module/Model/Observer.php
class Vendor_Module_Model_Observer
{
public function stockItemSaveBefore(Varien_Event_Observer $observer)
{
$item = $observer->getEvent()->getItem();
// Perform some action ...
}
}
I don't know what do you want to do with that information. You may want to send an email, save a log or just keep the qty in 0, regardless the action you'll take this is the way to do it.
add a comment |
You could create a custom module and an event observer hooked to the cataloginventory_stock_item_save_before
event then you can validate if the qty will be saved as negative and perform some action.
Configuration:
Vendor/Module/etc/config.xml
<global>
...
<events>
<cataloginventory_stock_item_save_before>
<observers>
<vendor_module_stock_item_save_before>
<class>vemdor_module/observer</class>
<method>stockItemSaveBefore</method>
</vendor_module_stock_item_save_before>
</observers>
</cataloginventory_stock_item_save_before>
</events>
</global>
...
Observer:
Vendor/Module/Model/Observer.php
class Vendor_Module_Model_Observer
{
public function stockItemSaveBefore(Varien_Event_Observer $observer)
{
$item = $observer->getEvent()->getItem();
// Perform some action ...
}
}
I don't know what do you want to do with that information. You may want to send an email, save a log or just keep the qty in 0, regardless the action you'll take this is the way to do it.
You could create a custom module and an event observer hooked to the cataloginventory_stock_item_save_before
event then you can validate if the qty will be saved as negative and perform some action.
Configuration:
Vendor/Module/etc/config.xml
<global>
...
<events>
<cataloginventory_stock_item_save_before>
<observers>
<vendor_module_stock_item_save_before>
<class>vemdor_module/observer</class>
<method>stockItemSaveBefore</method>
</vendor_module_stock_item_save_before>
</observers>
</cataloginventory_stock_item_save_before>
</events>
</global>
...
Observer:
Vendor/Module/Model/Observer.php
class Vendor_Module_Model_Observer
{
public function stockItemSaveBefore(Varien_Event_Observer $observer)
{
$item = $observer->getEvent()->getItem();
// Perform some action ...
}
}
I don't know what do you want to do with that information. You may want to send an email, save a log or just keep the qty in 0, regardless the action you'll take this is the way to do it.
answered Jan 26 '16 at 7:17
MauroNigreleMauroNigrele
2,577926
2,577926
add a comment |
add a comment |
I have seen constellations where qty is negative / < zero in a very small amount of client systems that we did not create from the scratch. The problem is, that the products with negative qty are "in stock/available" and can be bought by shop customers.
Instead of wasting computation time i would add a trigger:
delimiter //
CREATE TRIGGER negative_stock_to_zero BEFORE UPDATE ON cataloginventory_stock_item
FOR EACH ROW
BEGIN
IF NEW.qty < 0 THEN
NEW.qty = 0;
END IF;
END;//
delimiter;
Of course you could also check if backordering is enabled/disabled in the IF-Clause - but thats up to you.
add a comment |
I have seen constellations where qty is negative / < zero in a very small amount of client systems that we did not create from the scratch. The problem is, that the products with negative qty are "in stock/available" and can be bought by shop customers.
Instead of wasting computation time i would add a trigger:
delimiter //
CREATE TRIGGER negative_stock_to_zero BEFORE UPDATE ON cataloginventory_stock_item
FOR EACH ROW
BEGIN
IF NEW.qty < 0 THEN
NEW.qty = 0;
END IF;
END;//
delimiter;
Of course you could also check if backordering is enabled/disabled in the IF-Clause - but thats up to you.
add a comment |
I have seen constellations where qty is negative / < zero in a very small amount of client systems that we did not create from the scratch. The problem is, that the products with negative qty are "in stock/available" and can be bought by shop customers.
Instead of wasting computation time i would add a trigger:
delimiter //
CREATE TRIGGER negative_stock_to_zero BEFORE UPDATE ON cataloginventory_stock_item
FOR EACH ROW
BEGIN
IF NEW.qty < 0 THEN
NEW.qty = 0;
END IF;
END;//
delimiter;
Of course you could also check if backordering is enabled/disabled in the IF-Clause - but thats up to you.
I have seen constellations where qty is negative / < zero in a very small amount of client systems that we did not create from the scratch. The problem is, that the products with negative qty are "in stock/available" and can be bought by shop customers.
Instead of wasting computation time i would add a trigger:
delimiter //
CREATE TRIGGER negative_stock_to_zero BEFORE UPDATE ON cataloginventory_stock_item
FOR EACH ROW
BEGIN
IF NEW.qty < 0 THEN
NEW.qty = 0;
END IF;
END;//
delimiter;
Of course you could also check if backordering is enabled/disabled in the IF-Clause - but thats up to you.
answered Jun 30 '16 at 7:56
Michael LeissMichael Leiss
297312
297312
add a comment |
add a comment |
In the admin console under System -> Configuration
Under Catalog -> Inventory
You should see a setting in the Product Stock Options called Backorders. Set this to No Backorders.
Additionally set the "Qty for Item's Status to Become Out of Stock" setting to 0.
add a comment |
In the admin console under System -> Configuration
Under Catalog -> Inventory
You should see a setting in the Product Stock Options called Backorders. Set this to No Backorders.
Additionally set the "Qty for Item's Status to Become Out of Stock" setting to 0.
add a comment |
In the admin console under System -> Configuration
Under Catalog -> Inventory
You should see a setting in the Product Stock Options called Backorders. Set this to No Backorders.
Additionally set the "Qty for Item's Status to Become Out of Stock" setting to 0.
In the admin console under System -> Configuration
Under Catalog -> Inventory
You should see a setting in the Product Stock Options called Backorders. Set this to No Backorders.
Additionally set the "Qty for Item's Status to Become Out of Stock" setting to 0.
answered Jun 20 '17 at 1:27
Des HorsleyDes Horsley
1218
1218
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%2f98942%2fprevent-the-quantity-of-inventory-in-the-backend-products-is-negative%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