12
votes
How to get product QTY on product view page?
You can get Qty or other values like min qty by using that method.
echo $_product->getExtensionAttributes()->getStockItem()->getQty();
OR Complete Object Data
print_r($_product->...
9
votes
Accepted
How to get salable qty in magento 2.3.3?
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku');
$qty = $...
7
votes
Accepted
Magento : Show same product as separate in cart
Try this:
Copy the file app/code/core/Mage/Sales/Model/Quote/Item.php to app/code/local/Mage/Sales/Model/Quote/Item.php
Set the return as false in function representProduct()
7
votes
Accepted
Magento 2.3 Saleable stock qty does not equal Global Attribute Qty
Check inventory_reservation:
https://github.com/magento-engcom/msi/wiki/Salable-Quantity-Calculation-and-Mechanism-of-Reservations
If you don't wan't to use MSI (and stick to CatalogInventory_* from 2....
6
votes
Magento 2.3 : Getting qty from all assigned sources (Multi warehouse inventory) programmatically
$sourceItemsBySku = $this->getSourceItemsBySku->execute($product->getSku());
$config['stockData'][$productId] = [];
foreach ($sourceItemsBySku as $sourceItem) {
$source = $sourceItem->...
5
votes
How to extend sidebar.js to perform action on Qty change in Minicart Magento 2
you can follow below steps to solve the issue you have.
step 1:
update Box input html in the file checkout/view/frontend/web/template/minicart/item/default.html as below.
<div class="details-qty ...
4
votes
Accepted
Magento : Get Quantity of Added Product in cart_product_add_after Event
If you do var_dump($product->getData() you will see that there is a field with name qty_to_add in the data. This field contains the quantity which was requested to be add.
So to get what you want ...
4
votes
Accepted
Magento 2: Get qty of added product in cart
You can directly get the total qty of quote without using foreach by using this method
$quote->getItemsQty();
If you want to check in order object then you can get it by,
$order->...
4
votes
Accepted
How to get the Qty left in stock of a particular product in Magento 2
If you want for all products then you can use Only X left Threshold Configuration option from Store > Configuration > Catalog > Inventory. If you set the Qty 20 and If your product Qty is ...
4
votes
Accepted
Magento 2 how to do minicart ajax update
There are two Methods of updating the minicart
Method 1: Using sections.xml
Create sections.xml file under app/code/Vendor/Module/etc/frontend directory
<?xml version="1.0"?>
<config ...
4
votes
Accepted
Magento 2: after get qty its show zero always
Try below way,
echo $_product->getExtensionAttributes()->getStockItem()->getQty();
To get product qty in list page, for testing you can use objectmanager after finished testing create this ...
3
votes
Accepted
How to restore items' Qtys for canceled orders
I finally found the solution. Just leaving the answer for possible future seekers:
The Magento\Sales\Model\Order has a method named cancel. It would restore Qty, payment, ...
Also there's a cron job ...
3
votes
Magento 2 Product quantity showing empty on Update Product details page
You have to override the below path in your custom theme
Base file path :
vendor/magento/module-checkout/view/frontend/templates/cart/item/configure/updatecart.phtml
Move To Theme file path
app/...
3
votes
Accepted
Magento 2 : Add to cart qty validation
This question explain this. It's because "e" can represent a floating number.
https://stackoverflow.com/questions/31706611/why-does-the-html-input-with-type-number-allow-the-letter-e-to-be-entered-in/...
3
votes
Accepted
How to update product qty and Stock Status update programmatically by product id : Magento 2
You can use below sample code
$product->setStockData(['qty' => $yourQty, 'is_in_stock' => 1]);
$product->setQuantityAndStockStatus(['qty' => $yourQty, 'is_in_stock' => 1]);
$product-...
3
votes
I have to disable the MSI and enable the usual qty field only in the magento 2.3.5 version
2.3 introduced a view table
Run this on your db
CREATE
OR REPLACE
VIEW `inventory_stock_1` AS select
distinct `legacy_stock_status`.`product_id` AS `product_id`,
`legacy_stock_status`.`...
2
votes
How to get product QTY on product view page?
You should be able to get with this piece of code below:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\...
2
votes
Display quantity with "if conditions"
<?php if (Mage::app()->getStore()->getId() == 5):?>
<div class="availability-qty">
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"...
2
votes
Accepted
Magento 2 - Get product qty and special price from product collection
Its because of Qty and Special Price both are external attributes of product,so if you directly called via $item then you will not get the value for the same
Try below code :
You can get Qty or ...
2
votes
How to display stock quantity only for simple products?
You can try below condition to display stock quantity if its simple product only
if($_product->getTypeId() == 'simple'){
//your code
}
It will return configurable or simple
2
votes
How to get quantity of each product in cart magento 1.9
You can get product quantity like this :
$quote = Mage::helper('checkout/cart')->getCart()->getQuote();
$product = [];
foreach ($quote->getAllItems() as $item) {
$product[]= array (
...
2
votes
Magento 2.3 : Getting qty from all assigned sources (Multi warehouse inventory) programmatically
You need to use Source Item management APIs:
https://devdocs.magento.com/guides/v2.3/rest/modules/inventory/manage-source-items.html
For example, to retrieve all Quantities among all Sources where ...
2
votes
Accepted
Magento 2.3.2: How to override a Inventory Deduction API model?
There are many mistakes in your class.
1. You must include full path of the class for GetSourceItemBySourceCodeAndSku
2. You should call the parent __construct method.
3. Copy the exact argument list ...
2
votes
Magento 1.9 - CCAvenue Orders Automatically Cancelling
I cannot tell you the reason why the order was canceled. There could be a lot of reasons
payment processor sent a message back for canceling the order
someone actually canceled it from admin
,,,
But ...
2
votes
Accepted
Magento2.3 - Add Quantity Increment/Decrement on Category Page
Found the solution by adding this code to the theme product listing phtml file.
app/design/frontend/Sm/destino/Magento_Catalog/templates/product/list.phtml
<div class="box-tocart">
...
2
votes
I have to disable the MSI and enable the usual qty field only in the magento 2.3.5 version
Try to run the below command and check if it works!
php bin/magento module:disable -f Magento_Inventory Magento_InventoryAdminUi Magento_InventoryApi Magento_InventoryBundleProduct ...
2
votes
Magento 2 add Dropdown Quantity Box In Checkout Cart Page
Add checkout_cart_item_renderers.xml to your module
app/code/VendoreName/ModuleName/view/frontend/layout
checkout_cart_item_renderers.xml
<?xml version="1.0"?>
<page xmlns:xsi=&...
2
votes
M2: Can't decrease qty in cart: Attention The requested qty is not available
naviagte to vendor\magento\module-catalog-inventory\Model\Quote\Item\QuantityValidator inside this directory you will see a file with the name QuoteItemQtyList.php
Open it and replace this file with ...
1
vote
Add to cart one product with different size at once in product listing page magento 2.3
This functionality is achieved by customization.
I have mention Cart class to pass selected variant into the cart and save it.
class Cart extends \Magento\Framework\App\Action\Action
{
protected ...
1
vote
Accepted
how to add negative qty product into cart in magento. 2
Try the following way:
app/code/SR/MagentoCommunity/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
qty × 89magento2 × 53
product × 20
magento2.3 × 11
cart × 10
magento-1.9 × 9
addtocart × 8
magento-2.1 × 6
price × 6
qty-increment × 6
products × 4
stock × 4
inventory × 4
ajax × 3
shopping-cart × 3
mini-cart × 3
quantity × 3
multi-source-inventory × 3
php × 2
orders × 2
configurable-product × 2
product-attribute × 2
upgrade × 2
rest-api × 2
knockoutjs × 2