{"id":298943,"date":"2021-08-03T05:31:27","date_gmt":"2021-08-03T05:31:27","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=298943"},"modified":"2024-11-12T05:55:36","modified_gmt":"2024-11-12T05:55:36","slug":"magento-2-development-22-helper","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/","title":{"rendered":"Magento 2 Development 25: Helper"},"content":{"rendered":"\n<p>One very important concept that is widely used in Magento is Helper. So here we will learn what is helper and how to use them.<\/p>\n\n\n\n<p>In Magento 2 development, it&#8217;s smart to put all commonly used functions into a single helper class. <\/p>\n\n\n\n<p>This way, a <a href=\"https:\/\/webkul.com\/magento-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 development company<\/a> can keep the code clean and avoid repetition, following the DRY principle.<\/p>\n\n\n\n<p>By grouping I mean we create different helper which takes care of different things if putting all the methods in a single class become too cumbersome. <\/p>\n\n\n\n<p>One such example of grouping that you frequently observe in Magento is a helper to handle all email-related tasks.<\/p>\n\n\n\n<p>The helpers can be injected anywhere (i.e. in Blocks, Controllers, templates, etc) so that we can access the methods of that helper class.<\/p>\n\n\n\n<p>Injection of the class is just a fancy term for &#8220;mentioning the class in the constructor&#8221; so that we can create the object of that class.<\/p>\n\n\n\n<p>In this blog, for now, I will only create a single function to get the customer id. We can not get the customer id from the session if all the caches are enabled. <\/p>\n\n\n\n<p>So we need to do some hacks, which we will do later. If you remember we have used the customer id in 3-4 places. <\/p>\n\n\n\n<p>And everywhere we have used the session to get it. Now if we have to implement the hack, we will have to update the code in 3-4 places. <\/p>\n\n\n\n<p>Which is not ideal. So we will create a function in Helper to get the customer id. And we will call it everywhere else where the customer id is needed. <\/p>\n\n\n\n<p>So now we have to change only one function if we do some changes later. Note that we will and can keep adding more functions to the helper as we see fit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Creating and Using the Helper<\/h2>\n\n\n\n<p>To create the helpers we use a new folder named Helper inside the module directory. By default, we create a helper with the name Data. <\/p>\n\n\n\n<p>But we can use any name. Let&#8217;s create the helper as <em>Helper\/Data.php<\/em><\/p>\n\n\n\n<p>Code for <em>Helper\/Data.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Helper;\n\nuse Magento\\Customer\\Model\\Session;\n\nclass Data extends \\Magento\\Framework\\App\\Helper\\AbstractHelper\n{\n    \/**\n     * @var Magento\\Customer\\Model\\Session\n     *\/\n    protected $customerSession;\n    \n    \/**\n     * Dependency Initilization\n     *\n     * @param Session $customerSession\n     * @param \\Magento\\Framework\\App\\Helper\\Context $context\n     *\/\n    public function __construct(\n        Session $customerSession,\n        \\Magento\\Framework\\App\\Helper\\Context $context\n    ) {\n        $this-&gt;customerSession = $customerSession;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Get Customer Id\n     *\n     * @return int\n     *\/\n    public function getCustomerId()\n    {\n        $customerId = $this-&gt;customerSession-&gt;getCustomerId();\n        return $customerId;\n    }\n}<\/pre>\n\n\n\n<p>Since this is a helper, we have extended the default helper class. And we have created a method to get the customer id.<\/p>\n\n\n\n<p>Now let&#8217;s quickly update all the codes where we have used the customer id. We will have to edit <em>Block\/BlogList.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Block\/BlogList.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Block;\n\nclass BlogList extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory\n     *\/\n    protected $blogCollection;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        array $data = &#091;]\n    ) {\n        $this-&gt;blogCollection = $blogCollection;\n        $this-&gt;helper = $helper;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Get Blog List\n     *\n     * @return \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    public function getBlogs()\n    {\n        $customerId = $this-&gt;helper-&gt;getCustomerId();\n        $collection = $this-&gt;blogCollection-&gt;create();\n        $collection-&gt;addFieldToFilter(&#039;user_id&#039;, &#091;&#039;eq&#039;=&gt;$customerId])-&gt;setOrder(&#039;updated_at&#039;, &#039;DESC&#039;);\n        return $collection;\n    }\n}<\/pre>\n\n\n\n<p>As you can see here, we have removed the session codes. And injected the helper class in the constructor and called the <strong>getCustomerId<\/strong> function.<\/p>\n\n\n\n<p>We also have to edit the <em>Controller\/Manage\/Edit.php<\/em><\/p>\n\n\n\n<p>Updated code for  <em>Controller\/Manage\/Edit.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Controller\\Manage;\n\nuse Magento\\Customer\\Controller\\AbstractAccount;\nuse Magento\\Framework\\App\\Action\\Context;\nuse Magento\\Framework\\View\\Result\\PageFactory;\n\nclass Edit extends AbstractAccount\n{\n    \/**\n     * @var Magento\\Framework\\View\\Result\\PageFactory\n     *\/\n    protected $resultPageFactory;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\BlogFactory\n     *\/\n    protected $blogFactory;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * @var \\Magento\\Framework\\Message\\ManagerInterface\n     *\/\n    protected $messageManager;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param Context $context\n     * @param PageFactory $resultPageFactory\n     * @param \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param \\Magento\\Framework\\Message\\ManagerInterface $messageManager\n     *\/\n    public function __construct(\n        Context $context,\n\t    PageFactory $resultPageFactory,\n        \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        \\Magento\\Framework\\Message\\ManagerInterface $messageManager\n    ) {\n\t    $this-&gt;resultPageFactory = $resultPageFactory;\n\t    $this-&gt;blogFactory = $blogFactory;\n\t    $this-&gt;helper = $helper;\n\t    $this-&gt;messageManager = $messageManager;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Provides content\n     *\n     * @return Magento\\Framework\\View\\Result\\Page\n     * @return Magento\\Framework\\Controller\\Result\\Redirect\n     *\/\n    public function execute()\n    {\n        $blogId = $this-&gt;getRequest()-&gt;getParam(&#039;id&#039;);\n        $customerId = $this-&gt;helper-&gt;getCustomerId();\n        $isAuthorised = $this-&gt;blogFactory-&gt;create()\n                                    -&gt;getCollection()\n                                    -&gt;addFieldToFilter(&#039;user_id&#039;, $customerId)\n                                    -&gt;addFieldToFilter(&#039;entity_id&#039;, $blogId)\n                                    -&gt;getSize();\n        if (!$isAuthorised) {\n            $this-&gt;messageManager-&gt;addError(__(&#039;You are not authorised to edit this blog.&#039;));\n            return $this-&gt;resultRedirectFactory-&gt;create()-&gt;setPath(&#039;blog\/manage&#039;);\n        }\n\n        $resultPage = $this-&gt;resultPageFactory-&gt;create();\n        $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;set(__(&#039;Edit Blog&#039;));\n        $layout = $resultPage-&gt;getLayout();\n        return $resultPage;\n    }\n}<\/pre>\n\n\n\n<p>And also <em>Controller\/Manage\/Save.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Controller\/Manage\/Save.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Controller\\Manage;\n\nuse Magento\\Customer\\Controller\\AbstractAccount;\nuse Magento\\Framework\\App\\Action\\Context;\n\nclass Save extends AbstractAccount\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\BlogFactory\n     *\/\n    protected $blogFactory;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * @var \\Magento\\Framework\\Message\\ManagerInterface\n     *\/\n    protected $messageManager;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param Context $context\n     * @param \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param \\Magento\\Framework\\Message\\ManagerInterface $messageManager\n     *\/\n    public function __construct(\n        Context $context,\n        \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        \\Magento\\Framework\\Message\\ManagerInterface $messageManager\n    ) {\n        $this-&gt;blogFactory = $blogFactory;\n        $this-&gt;helper = $helper;\n        $this-&gt;messageManager = $messageManager;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Provides content\n     *\n     * @return Magento\\Framework\\Controller\\Result\\Redirect\n     *\/\n    public function execute()\n    {\n        $data = $this-&gt;getRequest()-&gt;getParams();\n        $customerId = $this-&gt;helper-&gt;getCustomerId();\n        if (isset($data&#091;&#039;id&#039;]) &amp;&amp; $data&#091;&#039;id&#039;]) {\n            $isAuthorised = $this-&gt;blogFactory-&gt;create()\n                                        -&gt;getCollection()\n                                        -&gt;addFieldToFilter(&#039;user_id&#039;, $customerId)\n                                        -&gt;addFieldToFilter(&#039;entity_id&#039;, $data&#091;&#039;id&#039;])\n                                        -&gt;getSize();\n            if (!$isAuthorised) {\n                $this-&gt;messageManager-&gt;addError(__(&#039;You are not authorised to edit this blog.&#039;));\n                return $this-&gt;resultRedirectFactory-&gt;create()-&gt;setPath(&#039;blog\/manage&#039;);\n            } else {\n                $model = $this-&gt;blogFactory-&gt;create()-&gt;load($data&#091;&#039;id&#039;]);\n                $model-&gt;setTitle($data&#091;&#039;title&#039;])\n                    -&gt;setContent($data&#091;&#039;content&#039;])\n                    -&gt;save();\n                $this-&gt;messageManager-&gt;addSuccess(__(&#039;You have updated the blog successfully.&#039;));\n            }\n        } else {\n            $model = $this-&gt;blogFactory-&gt;create();\n            $model-&gt;setData($data);\n            $model-&gt;setUserId($customerId);\n            $model-&gt;save();\n            $this-&gt;messageManager-&gt;addSuccess(__(&#039;Blog saved successfully.&#039;));\n        }        \n        return $this-&gt;resultRedirectFactory-&gt;create()-&gt;setPath(&#039;blog\/manage&#039;);\n    }\n}<\/pre>\n\n\n\n<p>One more file that we have to edit is <em>Controller\/Manage\/Delete.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Controller\/Manage\/Delete.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Controller\\Manage;\n\nuse Magento\\Customer\\Controller\\AbstractAccount;\nuse Magento\\Framework\\App\\Action\\Context;\n\nclass Delete extends AbstractAccount\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\BlogFactory\n     *\/\n    protected $blogFactory;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * @var \\Magento\\Framework\\Serialize\\Serializer\\Json\n     *\/\n    protected $jsonData;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param Context $context\n     * @param \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param \\Magento\\Framework\\Serialize\\Serializer\\Json $jsonData\n     *\/\n    public function __construct(\n        Context $context,\n        \\Webkul\\BlogManager\\Model\\BlogFactory $blogFactory,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        \\Magento\\Framework\\Serialize\\Serializer\\Json $jsonData\n    ) {\n        $this-&gt;blogFactory = $blogFactory;\n        $this-&gt;helper = $helper;\n        $this-&gt;jsonData = $jsonData;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Provides content\n     *\n     * @return Magento\\Framework\\Controller\\Result\\Redirect\n     *\/\n    public function execute()\n    {\n        $blogId = $this-&gt;getRequest()-&gt;getParam(&#039;id&#039;);\n        $customerId = $this-&gt;helper-&gt;getCustomerId();\n        $isAuthorised = $this-&gt;blogFactory-&gt;create()\n                                    -&gt;getCollection()\n                                    -&gt;addFieldToFilter(&#039;user_id&#039;, $customerId)\n                                    -&gt;addFieldToFilter(&#039;entity_id&#039;, $blogId)\n                                    -&gt;getSize();\n        if (!$isAuthorised) {\n            $msg=__(&#039;You are not authorised to delete this blog.&#039;);\n            $success=0;\n        } else {\n            $model = $this-&gt;blogFactory-&gt;create()-&gt;load($blogId);\n            $model-&gt;delete();\n            $msg=__(&#039;You have successfully deleted the blog.&#039;);\n            $success=1;\n        }     \n        $this-&gt;getResponse()-&gt;setHeader(&#039;Content-type&#039;, &#039;application\/javascript&#039;);\n        $this-&gt;getResponse()-&gt;setBody(\n            $this-&gt;jsonData-&gt;serialize(\n                    &#091;\n                        &#039;success&#039; =&gt; $success,\n                        &#039;message&#039; =&gt; $msg\n                    ]\n                ));\n    }\n}<\/pre>\n\n\n\n<p>Now we have created and used a helper. Please verify all the pages that these changes affect. <\/p>\n\n\n\n<p>And <strong>please make a habit of checking\/verifying the changes even if it&#8217;s a minor<\/strong> <strong>change<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cacheable<\/h2>\n\n\n\n<p>One more thing that I missed earlier is the use of a cacheable argument. By default, Magento cached all pages. <\/p>\n\n\n\n<p>So if you enable all caches and check the blog listing page you will see some confusing results.<\/p>\n\n\n\n<p>Magento recommends that all public pages (pages that can be accessed without sign-in) must be cacheable. <\/p>\n\n\n\n<p>That means all pages such as the category page, product page, and cms page are cached. <\/p>\n\n\n\n<p>And it makes sense because the public pages are get frequently accessed and the data on those pages do not change based on who the user is.<\/p>\n\n\n\n<p>However, for all non-public pages (those pages which can be accessed only after logging in), we should disable the cache if the data is not static for that page. <\/p>\n\n\n\n<p>We have not yet created any public page, we will do in the next blogs. So in our case, the private pages are blog listing, blog edit page, and blog add page. <\/p>\n\n\n\n<p>We do not care blog add page because it is static we just show a blank form. But for the other two pages, we will have to disable the cache. Which we can do from the layout xml file.<\/p>\n\n\n\n<p>So let&#8217;s first edit the <em>view\/frontend\/layout\/blogmanager_manage_index.xml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/layout\/blogmanager_manage_index.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;update handle=&quot;customer_account&quot;\/&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Webkul\\BlogManager\\Block\\BlogList&quot; name=&quot;blogmanager.blog.list&quot; template=&quot;Webkul_BlogManager::list.phtml&quot; cacheable=&quot;false&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Here we have done a very minor change. We have just added <strong>cacheable=&#8221;false&#8221;<\/strong> in the node. Now this page won&#8217;t be cached. <\/p>\n\n\n\n<p>Note that if there were multiple blocks then adding <strong>cacheable=&#8221;false&#8221;<\/strong> in any one of them will make the whole page non-cacheable. <\/p>\n\n\n\n<p>That means we can not say that cache this block and not this in a page.<\/p>\n\n\n\n<p>Let&#8217;s edit the other pages also <em>view\/frontend\/layout\/blogmanager_manage_edit.xml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/layout\/blogmanager_manage_edit.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;update handle=&quot;customer_account&quot;\/&gt;\n    &lt;head&gt;\n\t\t&lt;css src=&quot;Webkul_BlogManager::css\/style.css&quot;\/&gt;\n\t&lt;\/head&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Webkul\\BlogManager\\Block\\Blog&quot; name=&quot;blogmanager.blog.edit&quot; template=&quot;Webkul_BlogManager::edit.phtml&quot; cacheable=&quot;false&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Now it will work fine even if we enable all caches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Show Few More Columns<\/h2>\n\n\n\n<p>It is not related to the previous topics. But it is a minor change so I will append it to this blog. <\/p>\n\n\n\n<p>As you can see there are various important details are missing from the blog list on the seller side. <\/p>\n\n\n\n<p>We will do some changes to show the status, created at, and updated at on the grid.<\/p>\n\n\n\n<p>First, we will edit the phtml file <em>view\/frontend\/templates\/list.phtml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/frontend\/templates\/list.phtml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;div class=&quot;blog-list-table-container&quot;&gt;\n    &lt;table class=&quot;blog-list-table&quot;&gt;\n        &lt;tr class=&quot;blog-list-table-head&quot;&gt;\n            &lt;th class=&quot;blog-list-table-id&quot;&gt;\n                &lt;?= __(&quot;Id&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-title&quot;&gt;\n                &lt;?= __(&quot;Title&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-content&quot;&gt;\n                &lt;?= __(&quot;Content&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-status&quot;&gt;\n                &lt;?= __(&quot;Status&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-date&quot;&gt;\n                &lt;?= __(&quot;Updated At&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-date&quot;&gt;\n                &lt;?= __(&quot;Created At&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-action-edit&quot;&gt;\n                &lt;?= __(&quot;Edit&quot;)?&gt;\n            &lt;\/th&gt;\n            &lt;th class=&quot;blog-list-table-action-delete&quot;&gt;\n                &lt;?= __(&quot;Delete&quot;)?&gt;\n            &lt;\/th&gt;\n        &lt;\/tr&gt;\n        &lt;?php\n        $blogs = $block-&gt;getBlogs();\n        $statuses = $escaper-&gt;escapeHtml($block-&gt;getStatuses());\n        foreach ($blogs as $blog) {?&gt;\n        &lt;tr class=&quot;blog-list-table-row&quot;&gt;\n            &lt;td class=&quot;blog-list-table-id&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($blog-&gt;getId())?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-title&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($blog-&gt;getTitle())?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-content&quot;&gt;\n                &lt;?= substr($escaper-&gt;escapeHtml($blog-&gt;getContent()), 0, 20).&#039;...&#039;?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-status&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($statuses&#091;$escaper-&gt;escapeHtml($blog-&gt;getStatus())])?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-date&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($block-&gt;getFormattedDate($escaper-&gt;escapeHtml($blog-&gt;getUpdatedAt())))?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-date&quot;&gt;\n                &lt;?= $escaper-&gt;escapeHtml($block-&gt;getFormattedDate($escaper-&gt;escapeHtml($blog-&gt;getCreatedAt())))?&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-action blog-list-table-action-edit&quot;&gt;\n                &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/edit&#039;, &#091;&#039;id&#039;=&gt;$blog-&gt;getId()]))?&gt;&quot;&gt;\n                    &lt;?= __(&#039;Edit&#039;) ?&gt;\n                &lt;\/a&gt;\n            &lt;\/td&gt;\n            &lt;td class=&quot;blog-list-table-action blog-list-table-action-delete&quot;&gt;\n                &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/manage\/delete&#039;, &#091;&#039;id&#039;=&gt;$blog-&gt;getId()]))?&gt;&quot;&gt;\n                    &lt;?= __(&#039;Delete&#039;) ?&gt;\n                &lt;\/a&gt;\n            &lt;\/td&gt;\n        &lt;\/tr&gt;\n        &lt;?php } ?&gt;\n    &lt;\/table&gt;\n&lt;\/div&gt;\n&lt;script type=&quot;text\/x-magento-init&quot;&gt;\n    {\n        &quot;*&quot;: {\n            &quot;bloglist&quot;: &quot;&quot;\n        }\n    }\n&lt;\/script&gt;<\/pre>\n\n\n\n<p>In the head section of the table, we have added the three columns, and similarly in the body section also. <\/p>\n\n\n\n<p>We have called a method <strong><code>getStatuses<\/code><\/strong> which will return an associative array with an integer (0 or 1) as the key and the status label as the value. Using this we can show the label based on the value.<\/p>\n\n\n\n<p>One more thing is that we are not showing the Date directly from the database.<\/p>\n\n\n\n<p>We have created the <strong>getFormattedDate<\/strong> function in the block class which will format the date in a nice readable format.<\/p>\n\n\n\n<p>Now let&#8217;s create these methods in <em>Block\/BlogList.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Block\/BlogList.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Block;\n\nclass BlogList extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory\n     *\/\n    protected $blogCollection;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\Blog\\Status\n     *\/\n    protected $blogStatus;\n\n    \/**\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface\n     *\/\n    protected $date;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param \\Webkul\\BlogManager\\Model\\Blog\\Status $blogStatus\n     * @param \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface $date\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        \\Webkul\\BlogManager\\Model\\Blog\\Status $blogStatus,\n        \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface $date,\n        array $data = &#091;]\n    ) {\n        $this-&gt;blogCollection = $blogCollection;\n        $this-&gt;helper = $helper;\n        $this-&gt;blogStatus = $blogStatus;\n        $this-&gt;date = $date;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Get Blog List\n     *\n     * @return \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    public function getBlogs()\n    {\n        $customerId = $this-&gt;helper-&gt;getCustomerId();\n        $collection = $this-&gt;blogCollection-&gt;create();\n        $collection-&gt;addFieldToFilter(&#039;user_id&#039;, &#091;&#039;eq&#039;=&gt;$customerId])-&gt;setOrder(&#039;updated_at&#039;, &#039;DESC&#039;);\n        return $collection;\n    }\n\n    \/**\n     * Get Blog Status\n     *\n     * @return boolean\n     *\/\n    public function getStatuses()\n    {\n        $statuses = &#091;];\n        foreach ($this-&gt;blogStatus-&gt;toOptionArray() as $status) {\n            $statuses&#091;$status&#091;&#039;value&#039;]] = $status&#091;&#039;label&#039;];\n        }\n        return $statuses;\n    }\n\n    \/**\n     * Get Formatted Date\n     *\n     * @param date $date\n     * @return date\n     *\/\n    public function getFormattedDate($date)\n    {\n        return $this-&gt;date-&gt;date($date)-&gt;format(&#039;d\/m\/y H:i&#039;);\n    }\n}<\/pre>\n\n\n\n<p>In <strong>getStatuses,<\/strong> we have used the class that we created to get the statuses for the UI component.<\/p>\n\n\n\n<p>It is a good practice because if we want to add more statuses then we will have to change only in one file.<\/p>\n\n\n\n<p>To get the formatted date we have used <strong>\\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface<\/strong> which will return the date in the mentioned format. <\/p>\n\n\n\n<p>If we want to convert then we have to pass the timestamp in <strong>date() <\/strong>and if we leave it empty then the current timestamp will be used. Note that this will return the date based on the locale.<\/p>\n\n\n\n<p>Now you will see all the details like,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"516\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png\" alt=\"2021-08-03_10-36\" class=\"wp-image-299071\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-300x129.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-250x108.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-768x331.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1536x661.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36.png 1810w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p><br><\/p>\n\n\n\n<p>Next Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\">Magento 2 Development 26: Blog Listing<\/a><\/p>\n\n\n\n<p>Previous Blog -&gt;&nbsp;<a href=\"https:\/\/webkul.com\/blog\/magento-2-development-21-loading-magentos-data\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Development 24: Loading Magento\u2019s Data<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One very important concept that is widely used in Magento is Helper. So here we will learn what is helper and how to use them. In Magento 2 development, it&#8217;s smart to put all commonly used functions into a single helper class. This way, a Magento 2 development company can keep the code clean and <a href=\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[2056,2460,2070],"class_list":["post-298943","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-magento","tag-magento-2","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento 2 Development 25: Helper - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2 Development 25: Helper - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"One very important concept that is widely used in Magento is Helper. So here we will learn what is helper and how to use them. In Magento 2 development, it&#8217;s smart to put all commonly used functions into a single helper class. This way, a Magento 2 development company can keep the code clean and [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-03T05:31:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-12T05:55:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Chouhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"Magento 2 Development 25: Helper\",\"datePublished\":\"2021-08-03T05:31:27+00:00\",\"dateModified\":\"2024-11-12T05:55:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\"},\"wordCount\":1151,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png\",\"keywords\":[\"magento\",\"Magento 2\",\"Magento2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\",\"name\":\"Magento 2 Development 25: Helper - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png\",\"datePublished\":\"2021-08-03T05:31:27+00:00\",\"dateModified\":\"2024-11-12T05:55:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36.png\",\"width\":1810,\"height\":779,\"caption\":\"2021-08-03_10-36\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2 Development 25: Helper\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2 Development 25: Helper - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2 Development 25: Helper - Webkul Blog","og_description":"One very important concept that is widely used in Magento is Helper. So here we will learn what is helper and how to use them. In Magento 2 development, it&#8217;s smart to put all commonly used functions into a single helper class. This way, a Magento 2 development company can keep the code clean and [...]","og_url":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-08-03T05:31:27+00:00","article_modified_time":"2024-11-12T05:55:36+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"Magento 2 Development 25: Helper","datePublished":"2021-08-03T05:31:27+00:00","dateModified":"2024-11-12T05:55:36+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/"},"wordCount":1151,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png","keywords":["magento","Magento 2","Magento2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/","url":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/","name":"Magento 2 Development 25: Helper - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36-1200x516.png","datePublished":"2021-08-03T05:31:27+00:00","dateModified":"2024-11-12T05:55:36+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_10-36.png","width":1810,"height":779,"caption":"2021-08-03_10-36"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2 Development 25: Helper"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/298943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=298943"}],"version-history":[{"count":12,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/298943\/revisions"}],"predecessor-version":[{"id":473550,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/298943\/revisions\/473550"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=298943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=298943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=298943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}