Hot answers tagged

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->...
user avatar
  • 1,187
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 = $...
user avatar
  • 661
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()
user avatar
  • 1,355
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....
user avatar
  • 552
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->...
user avatar
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 ...
user avatar
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 ...
user avatar
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->...
user avatar
  • 17.4k
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 ...
user avatar
  • 17.4k
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 ...
user avatar
  • 6,159
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 ...
user avatar
  • 1,666
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 ...
user avatar
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/...
user avatar
  • 1,873
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/...
user avatar
  • 113
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-...
user avatar
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`.`...
user avatar
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\...
user avatar
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"...
user avatar
  • 5,738
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 ...
user avatar
  • 9,570
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
user avatar
  • 1,539
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 ( ...
user avatar
  • 16.5k
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 ...
user avatar
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 ...
user avatar
  • 36
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 ...
user avatar
  • 195k
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"> ...
user avatar
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 ...
user avatar
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=&...
user avatar
  • 5,782
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 ...
user avatar
  • 1,664
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 ...
user avatar
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="...
user avatar
  • 34.1k

Only top scored, non community-wiki answers of a minimum length are eligible