GraphQL Route query to fetch 301 redirect URL data in Magento 2.

GraphQL Route Query is used to fetch URL-related data for entity-type products, categories, or CMS pages. This query will be helpful while you are using PWA stuff to render proper pages based on the older 301 redirect URL.

If you have modified any URL for 301 permanent redirects and your e-commerce app running on PWA, while a user comes to your site and tries to hit the older URL, it will be going to 404 pages because the older URL has been permanently redirected to a new URL.

urlResolver() query is deprecated so try to avoid that query and use the latest route() Query for future proof your system. Continue reading “GraphQL Route query to fetch 301 redirect URL data in Magento 2.”

Javascript forEach: How to iterate list items by Javascript?

You can iterate over given HTML list items using javascript by fetching li tags object with querySelectorAll()

Based on the response to the document.querySelectorAll() object, you need to convert the object to an array type that will be supported with forEach in javascript.

Let’s take a simple UL <LI> tag structure to fetch list items text value using forEach, Continue reading “Javascript forEach: How to iterate list items by Javascript?”

How to check radio button is checked/selected or not by Javascript only?

You can validate the radio button in a form is selected or not with the help of javascript.

<div class="radio-buttons">
      <div class="male">
        <input class="form-radio" type="radio" name="gender" id="radio1" value="male">
        <label class="form-check-label" for="radio1">Male</label>
      </div>

      <div class="female">
        <input class="form-radio" type="radio" name="gender" id="radio2" value="female">
        <label class="form-check-label" for="radio2">Female</label>
      </div>
</div>

Here you can check it by document.querySelectorAll() with the help of attribute name, Continue reading “How to check radio button is checked/selected or not by Javascript only?”