How to get current date time programmatically in Magento 2?

Magento 2 Fetch Current Date Time programmatically by use of the DateTime() method.

If you want to fetch the GMT Date time Check the link, Magento 2 GMT date time Format.

Just use the given code to display the current date and time from the system. Continue reading “How to get current date time programmatically in Magento 2?”

How to set stores URL configuration by env.php file in magento 2?

Magento env.php file stores  Environment specific configuration and system-related sensitive data.

With the help of the ‘system’ array node, A System node locks the provided configuration values in the env.php file and disables that field in the admin panel.

Sensitive values might be API keys for the connector, Payment related Stuff, Email Addresses, URLs, and Private Contact related information.

We will set the URL value with the env.php file.

You can’t able to modify it from the Stores -> Configuration -> General -> Web -> Base URL field. Continue reading “How to set stores URL configuration by env.php file in magento 2?”

Magento 2 Update Product Stock Inventory by Rest API.

You can Update Product Stock related information by REST API with the use of endpoint URL /V1/products/:productSku/stockItems/:itemId.

You can manage Stock Inventory related data with REST API with the given payload as below.

Action: PUT

Header: Authorization: Bearer <ADMIN_TOKEN> Continue reading “Magento 2 Update Product Stock Inventory by Rest API.”