How to print a log with console.log() in knockout template?

Knockout JS with print a log message to the console at a development time.

You can trace or logs any object by the console.log in the knockout JS template.

You can log messages with the given syntax,

<div data-bind="text: console.log(' My Log:', $data)"></div>

Here When you refresh the page, you will see My Log: with your data output in the Browser console.

Just use the text data-bind attribute to log specific JS messages.

How to update product images by REST Web API Magento 2?

You can upload product images by REST API Magento with the PUT action and the help of /V1/products/<sku>.

Action: PUT

URL: <BASE_URL>/rest/V1/products/<SKU>
(Example URL: https://magento.test/rest/V1/products/my-sku)

Header: Authorization: Bearer <ADMIN TOKEN> Continue reading “How to update product images by REST Web API Magento 2?”

Get All Sales/Cart rules associated with product by REST API Magento 2.

You can retrieve all the Sales rules that are related to the given product by Cart Price Rule Search REST API in Magneto.

Let’s say product SKU “A10001” is associated with two different cart price rules and you want to fetch a list of all the sales rules that are associated with the given SKU.

Magento native supports Cart Rule Search Rest API which will be helpful to fetch products associated with cart rules. Continue reading “Get All Sales/Cart rules associated with product by REST API Magento 2.”