How to apply SortOrder on Search Criteria Repositories Magento 2?

Magento apply sort order for the search criteria interface repository by using Magento\Framework\Api\SortOrderBuilder Class.

You can do sorting by ASC or DESC order by any field type for a given search criteria repository.

$sortOrder = $this->sortOrderBuilder
            ->setField('created_at')  //FIELD_NAME
            ->setDirection(SortOrder::SORT_DESC) // SORT_TYPE
            ->create();

You can check the given code snippet to fetch orders by created date with the search criteria builder order repository. Continue reading “How to apply SortOrder on Search Criteria Repositories Magento 2?”

How to Enable Set up Google ReCaptcha in Magento 2?

Magento Supports Google ReCaptcha Out of the box from Magento 2.4 Version. You can set it up from the Magento admin panel.

Using Google ReCaptcha on your site, You can secure your website forms from some malicious attacks and bots to secure your different form details. Only Humans can submit the form and you do not have to worry about bot attacks.

Go To Stores -> Configuration -> Security -> Google ReCaptcha Storefront.
From here, you can set up any required reCAPTCHA for your store.

Google reCAPTCHA can be implemented in three ways from the admin panel, Continue reading “How to Enable Set up Google ReCaptcha in Magento 2?”

How to create customer attribute for specific website level Magento 2?

You can create user-defined customer attributes using Patch Data in Magento 2.

If you have some requirement to show customer attributes to only a given website in multi website setup.
This article displays customer attributes for specific website levels.

Let’s hope you have created a simple module,
Just create a new Data Patch file under the path, app/code/<Vendor>/<Modulename>/Setup/Patch/Data/CustomerAttributes.php

We have to create a new attribute called ‘mobile’ and display it on the customer registration page, and customer edit page. Continue reading “How to create customer attribute for specific website level Magento 2?”