How to generate random string or number in Magento 2?

In Magento 2, You can generate a random number or random string using core Magento\Framework\Math\Random class.

Using Random.php class you can generate a random string and random number with Magento Best Coding Practice and you don’t need to depend on PHP core function. Continue reading “How to generate random string or number in Magento 2?”

How to generate unique hash token in Magento 2?

In Magento 2, You can generate a unique hash token for your custom functionality where you need to pass id or variable as encrypted.

Magento uses this functionality, generate a unique hash token for reset password confirmation link.

If you want to do a generate unique token you need to use Core Magento\Framework\Math\Random class to accomplish your requirement. Continue reading “How to generate unique hash token in Magento 2?”

Get Shared Catalog data by id programmatically Magento 2.

Shared Catalog is the native functionality of B2B Magento Commerce. Magento gives you the ability to maintain shared catalogs with the custom pricing structure for different companies. A Public Default(General) Catalog will be available native with Magento B2B.

You can get Shared Catalog data by shared catalog id using programmatically.
Magento\SharedCatalog\Api\SharedCatalogRepositoryInterface Interface used to get,delete and save  Shared catalog data related stuff. Get Shared Catalog data by Customer group id Magento 2. Continue reading “Get Shared Catalog data by id programmatically Magento 2.”