create CMS static block store level programmatically in Magento 2.

Magento store with multiple store view having a feature like you can create multiple Static blocks with the same identifier with different store view.

Using multiple separate store view for the different store will helpful to display different content to the different store view.

You can add/create CMS Static block for only a specific store view using programmatically.

You can create/add any cms static block programmatically via Magento\Cms\Api\BlockRepositoryInterface interface and Magento\Cms\Model\BlockFactory Factory method with the use of above class set inside the __construct() method.

Continue reading “create CMS static block store level programmatically in Magento 2.”

Update CMS static block programmatically at store level Magento 2.

Magento 2 Contains the native functionality for multiple CMS static block with the same identifier for different store view.

You can update/edit any cms static block programmatically via Magento\Cms\Api\BlockRepositoryInterface interface and Magento\Cms\Model\BlockFactory Factory method.

We will update our CMS Block as per store view level, If you have multiple CMS static block with the same identifier for different store view, You can update only specific CMS static block using store id. Continue reading “Update CMS static block programmatically at store level Magento 2.”

How to prevent the use of ObjectManagaer in the Unit test Magento 2?

Magento 2 with the Unit test for a module, Avoid direct use of Helper\ObjectManager in a Unit test.

Many developers used the native Magento\Framework\TestFramework\Unit\Helper\ObjectManager class for creating mock and objects. Continue reading “How to prevent the use of ObjectManagaer in the Unit test Magento 2?”