Endpoint: PUT https://your-magento-site.com/rest/V1/products/SHE-211359BK/stockItems/2911 Headers: Authorization: Bearer {your_token} Content-Type: application/json Body: { “stock_item”: { “qty”: 50, “is_in_stock”: true, “manage_stock”: true, “use_config_manage_stock”: false } }
Category: Magento
How can I get an admin token in Magento 2 using the REST API?
To authenticate and obtain an admin token in Magento 2, send a POST request to the endpoint: https://your-magento-site.com/rest/V1/integration/admin/token Request payload: { “username”: “your_admin_username”, “password”: “your_admin_password” } If the credentials are valid, Magento returns a token like this: “abcd1234abcd5678abcd90efgh” ✅ Use this token in your subsequent API requests by adding it to the Authorization header as:… Continue reading How can I get an admin token in Magento 2 using the REST API?
Add Custom Attribute To Recently Viewed Products Widget
here is the solution for overiding the controllers Namespace/Module/etc/di.xml <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <type name=”MagentoCatalogUiDataProviderProductProductRenderCollectorComposite”> <arguments> <argument name=”productProviders” xsi:type=”array”> <item name=”sku” xsi:type=”object”>NamespaceModuleUiDataProviderProductListingCollectorSku</item> </argument> </arguments> </type> </config> Namespace/Module/etc/extension_attributes.xml <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Api/etc/extension_attributes.xsd”> <extension_attributes for=”MagentoCatalogApiDataProductRenderInterface”> <attribute code=”sku” type=”string”/> </extension_attributes> </config> Namespace/Module/etc/widget.xml <?xml version=”1.0″ encoding=”UTF-8″?> <widgets xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Widget:etc/widget.xsd”> <widget id=”catalog_recently_viewed”> <parameters> <parameter name=”show_attributes” xsi:type=”multiselect” required=”true” visible=”true”>… Continue reading Add Custom Attribute To Recently Viewed Products Widget
Get quantity in stock for items added in cart in JS
In your phtml file : <script type=”text/x-magento-init”> { “#idofyourdiv” : { “yourJSdefinedinRequireJS” : { “data1” : “data1”, “data2” : “data2”, “data3” : “data3”, } } } </script> In your JS : define([ ‘jquery’, ‘mage/translate’, ‘jquery/ui’ ], function ($, $t) { ‘use strict’; $.widget(‘mage.yourjsdefinedinrequirejs’, { options: { data1: data1, data2: data2, data3:data3 }, … …. …… Continue reading Get quantity in stock for items added in cart in JS
Magezon – Image gallery setting up
Download the zip file after the purchase, and unzip on the app/code folder. After the upgrade, deploy and di-compile commands, On the Website Admin backend Albums – Allows you to create collection of images and video albums. You can easily drag and drop multiple images. Please select the grid view for a better display. Category – Enables… Continue reading Magezon – Image gallery setting up
Increase the customer session on the website
The timeout occurring at short intervals was due to security measures triggered by user inactivity. To improve the same, For frontend (customer) sessions: Go to Stores > Configuration. Navigate to General > Web. Under Default Cookie Settings, adjust: Cookie Lifetime: Enter the number of seconds for the session duration (e.g., 86400 for 24 hours). Click… Continue reading Increase the customer session on the website
How to include a new field on the Shipment API in Magento2
Create a new field on the sales shipment table using the db-schema.xml file Then add the newfield on the extension attributes file app/code/JJ/DocumentNumber/etc extension_attributes.xml <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework/Extension/etc/extension_attributes.xsd”> <extension_attributes for=”MagentoSalesApiDataShipmentCreationArgumentsInterface”> <attribute code=”document_number” type=”string”/> </extension_attributes> </config> For saving the field di.xml <config xsi:noNamespaceSchemaLocation=”urn:magento:framework/ObjectManager/etc/config.xsd”> <type name=”MagentoSalesApiShipmentRepositoryInterface”> <plugin name=”custom_shipment_repository_plugin” type=”JJDocumentNumberPluginShipmentRepositoryPlugin”/> </type> </config> ShipmentRepositoryPlugin.php <?php namespace JJDocumentNumberPlugin; use MagentoSalesApiDataShipmentExtensionFactory; use MagentoSalesApiDataShipmentInterface; use MagentoSalesApiShipmentRepositoryInterface; class ShipmentRepositoryPlugin… Continue reading How to include a new field on the Shipment API in Magento2
How to solve the RDBMS error up on steup upgrade after MYSQL upgrade
Solution:- Please be assured that we checked and though the MySQL downgrade is not feasible once the MySQL version is upgraded. However, we did this workaround. Updated the required MariaDB version in: app/etc/di.xml from <item name=”MariaDB-(10.2-10.4)” xsi:type=”string”>^10.[2-4].</item> to <item name=”MariaDB-(10.2-10.5)” xsi:type=”string”>^10.[2-5].</item> and that fixed it.
Magento Show only tier prices for Level Customer- No promotional prices
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ use MagentoFrameworkPricingAmountAmountFactory; ?> <?php /** @var MagentoCatalogPricingRenderFinalPriceBox $block */ /** ex: MagentoCatalogPricingPriceRegularPrice */ /** @var MagentoFrameworkPricingPricePriceInterface $priceModel */ $priceModel = $block->getPriceType(‘regular_price’); /** ex: MagentoCatalogPricingPriceFinalPrice */ /** @var MagentoFrameworkPricingPricePriceInterface $finalPriceModel */ $finalPriceModel = $block->getPriceType(‘final_price’); $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix()… Continue reading Magento Show only tier prices for Level Customer- No promotional prices
How can I show product flags in SwissUp ProLabels based on customer groups in Magento?
Log in to your Magento Admin Panel. Navigate to SwissUp > ProLabels. Select the label you want to edit. In the label settings, look for the Customer Groups option. Choose the specific customer groups you want the label to be visible for. Save the changes and clear the cache if necessary.