2

When I'm trying to change the quantity of a product in the admin, it will not be stored in the database. This problem only occurs when the EAV cache is enabled.

The quantity input field has the name: "product[quantity_and_stock_status][qty]". If I save the product, javascript will create a new hidden input field with the name "product[stock_data][qty]". After saving the product, there will be a page refresh. After that page refresh, there is a POST request visible in the Network tab from my Chrome Developer Tools.

When I check the Request Payload in the tab Headers, both input field values are visible, I see the quantity_and_stock_status:

    Content-Disposition: form-data; name="product[quantity_and_stock_status][qty]"
    1700

And I see the stock_data:

    Content-Disposition: form-data; name="product[stock_data][qty]"
    1500

1700 is the value that I entered in the quantity field, but the value didn't change in the database, so it sets the old value (1500) in the input field: Product quantity

When I check the page source (after the page was saved), the JSON of the product form data contains quantity_and_stock_status and stock_data. But now the values are both 1500.

"product_form_data_source": {
  "type": "dataSource",
  "name": "product_form_data_source",
  "dataScope": "product_form",
  "config": {
    "data": {
      "product": {
        "status": "1",
        "name": "Target Power Star Air G3 Black",
        "sku": "330800",
        "price": "1.07",
        "tax_class_id": "4",
        "quantity_and_stock_status": {
          "is_in_stock": 1,
          "qty": 1500
        },
        "attribute_set_id": "11",
        "current_product_id": "1878",
        "stock_data": {
          "item_id": "1868",
          "product_id": "1878",
          "stock_id": "1",
          "qty": 1500,
          "min_qty": 0,
          "use_config_min_qty": "1",
          "is_qty_decimal": 0,
          "backorders": 2,
          "use_config_backorders": "1",
          "min_sale_qty": 1,
          "use_config_min_sale_qty": "1",
          "max_sale_qty": 10000,
          "use_config_max_sale_qty": "1",
          "is_in_stock": 1,
          "low_stock_date": null,
          "notify_stock_qty": 1,
          "use_config_notify_stock_qty": "1",
          "manage_stock": 1,
          "use_config_manage_stock": "1",
          "stock_status_changed_auto": "0",
          "use_config_qty_increments": "1",
          "qty_increments": 0,
          "use_config_enable_qty_inc": "1",
          "enable_qty_increments": 0,
          "is_decimal_divided": 0,
          "website_id": "0",
          "type_id": "simple",
          "min_qty_allowed_in_shopping_cart": "1"
        }
      }
    }
  }
}

(This is only the relevant info of the JSON)

Has anyone encountered this problem or could this be a Magento bug?

1

If you fetch issue with your new product type then simply make change in product_types.xml.

open product_types.xml and add to node type attribute isQty="true. e.g

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Magento/Catalog/etc/product_types.xsd">
    <type name="yournewproducttype" label="New Product Type" modelInstance="[NameSpace]\[Module]\Model\Product\Type\Credit" indexPriority="10" isQty="true" canUseQtyDecimals="false" sortOrder="25">
        <priceModel instance="[NameSpace]\[Module]\Model\Product\Type\Credit\Price" />
    </type>
    <composableTypes>
        <type name="yournewproducttype" />
    </composableTypes>
</config>

Hope so it's help you !!

0

I have the same problem. It seems to only happen on my custom product type but so far I haven't found a solution. Unless the product type doesn't have all the needed product attributes assigned to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.