{"id":389095,"date":"2023-06-30T12:13:02","date_gmt":"2023-06-30T12:13:02","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=389095"},"modified":"2023-06-30T12:13:09","modified_gmt":"2023-06-30T12:13:09","slug":"how-to-use-js-routing-component-in-prestashop-backoffice","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/","title":{"rendered":"How to use JS routing component in PrestaShop Backoffice"},"content":{"rendered":"\n<p>In this blog, we will learn how to use the Javascript routing component in the PrestaShop back office. Since the 1.7.8.0 version, you can use components without importing them. <code><strong>window.prestashop.component<\/strong><\/code> the object is used for this purpose.<br>These are some rules to understand the JS <a href=\"https:\/\/github.com\/PrestaShop\/PrestaShop\/blob\/1.7.8.0\/admin-dev\/themes\/new-theme\/js\/app\/utils\/init-components.js\" target=\"_blank\" rel=\"noreferrer noopener\">component<\/a><\/p>\n\n\n\n<p>i) Reusable components in BO will be available globally through <strong>window.prestashop<\/strong> object.<\/p>\n\n\n\n<p>ii) PrestaShop components will be grouped together and made available on all pages. So you have to decide on the controller page which components need to initialize.<\/p>\n\n\n\n<p>iii) Reusable components will be available as a namespace <strong>window.prestashop.component<\/strong>.<\/p>\n\n\n\n<p>iv) The namespace will contain classes like this <strong>prestashop.component.SomeComponent<\/strong>. If you want to get a new instance of SomeComponent, you call the new <strong>prestashop.component.SomeComponent(&#8230;params)<\/strong><\/p>\n\n\n\n<p>v) Reusable components will be available as initialized instances through <strong>window.prestashop.instance<\/strong>. These instances are initialized with default parameters by the <strong><a href=\"https:\/\/github.com\/PrestaShop\/PrestaShop\/blob\/1.7.8.0\/admin-dev\/themes\/new-theme\/js\/app\/utils\/init-components.js\">initComponents<\/a><\/strong> function.<\/p>\n\n\n\n<p>vi) A function <strong>initComponents<\/strong> available through <strong>prestashop.component<\/strong> is responsible for building <strong>window.prestashop.instance<\/strong>.<\/p>\n\n\n\n<p>Here, we are showing the process step by step with an example module \u2018<strong>wkjsrouting<\/strong>\u2018<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> <strong>Create the module class<\/strong><\/p>\n\n\n\n<p>Here, we have created the module class file \u201c<strong>wkjsrouting\/wkjsrouting.php<\/strong>\u201c<\/p>\n\n\n\n<p>In this class, we are initializing the module and redirecting the configuration page to modern page routes.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\ndeclare(strict_types=1);\n\nuse PrestaShop\\Module\\WkJsRouting\\Install\\Installer;\n\nif (!defined(&#039;_PS_VERSION_&#039;)) {\n    exit;\n}\n\nrequire_once __DIR__ . &#039;\/vendor\/autoload.php&#039;;\n\nclass WkJsRouting extends Module\n{\n    public $tabs = &#091;\n        &#091;\n            &#039;class_name&#039; =&gt; &#039;DemoPageController&#039;,\n            &#039;visible&#039; =&gt; true,\n            &#039;name&#039; =&gt; &#039;Demo page&#039;,\n            &#039;parent_class_name&#039; =&gt; &#039;CONFIGURE&#039;,\n        ],\n    ];\n\n    public function __construct()\n    {\n        $this-&gt;name = &#039;wkjsrouting&#039;;\n        $this-&gt;author = &#039;Webkul&#039;;\n        $this-&gt;version = &#039;1.0.0&#039;;\n        $this-&gt;ps_versions_compliancy = &#091;&#039;min&#039; =&gt; &#039;1.7.7.0&#039;, &#039;max&#039; =&gt; &#039;8.99.99&#039;];\n\n        parent::__construct();\n\n        $this-&gt;displayName = $this-&gt;l(&#039;Demo Module&#039;);\n        $this-&gt;description = $this-&gt;l(&#039;Javascript component Router usage in BO&#039;);\n    }\n\n    \/**\n     * @return bool\n     *\/\n    public function install()\n    {\n        if (!parent::install()) {\n            return false;\n        }\n\n        $installer = new Installer();\n\n        return $installer-&gt;install($this);\n    }\n\n    public function getContent()\n    {\n        $moduleAdminLink = Context::getContext()-&gt;link-&gt;getAdminLink(&#039;DemoPageController&#039;, true);\n        Tools::redirectAdmin($moduleAdminLink);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 2<\/strong>: <strong>Define routes<\/strong><br>Create routes.yml file inside the wkjsrouting\/config folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">demo_page_index:\n    path: demo-page\/\n    methods: &#091;GET]\n    defaults:\n        _controller: PrestaShop\\Module\\WkJsRouting\\Controller\\DemoPageController::indexAction\n        _legacy_controller: &#039;DemoPageController&#039;\n        _legacy_link: &#039;DemoPageController&#039;<\/pre>\n\n\n\n<p><strong>Step 3: Create a controller to handle the<\/strong> <strong>JS request<\/strong> <\/p>\n\n\n\n<p>Path: wkjsrouting\/src\/Controller\/DemoPageController.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\ndeclare(strict_types=1);\n\nnamespace PrestaShop\\Module\\WkJsRouting\\Controller;\n\nuse PrestaShopBundle\\Controller\\Admin\\FrameworkBundleAdminController;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass DemoPageController extends FrameworkBundleAdminController\n{\n    public function indexAction(): Response\n    {\n        return $this-&gt;render(&#039;@Modules\/wkjsrouting\/views\/templates\/admin\/demo_page.html.twig&#039;);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong> <strong>Create an installer class<\/strong><\/p>\n\n\n\n<p>Path: wkjsrouting\/src\/Install\/Installer.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\ndeclare(strict_types=1);\n\nnamespace PrestaShop\\Module\\WkJsRouting\\Install;\n\nuse Module;\n\nclass Installer\n{\n    \/**\n     * Module&#039;s installation entry point.\n     *\n     * @param Module $module\n     *\n     * @return bool\n     *\/\n    public function install(Module $module): bool\n    {\n        if (!$this-&gt;registerHooks($module)) {\n            return false;\n        }\n\n        return true;\n    }\n\n    \/**\n     * Register hooks for the module.\n     *\n     * @param Module $module\n     *\n     * @return bool\n     *\/\n    private function registerHooks(Module $module): bool\n    {\n        $hooks = &#091;];\n\n        return (bool) $module-&gt;registerHook($hooks);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 5:<\/strong> <strong>Create a view<\/strong><\/p>\n\n\n\n<p>Twig file\u00a0<strong>demo_page.html.twig,\u00a0<\/strong>path: wkjsrouting\/views\/templates\/admin\/demo_page.html.twig<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{% extends &#039;@PrestaShop\/Admin\/layout.html.twig&#039; %}\n\n{% block content %}\n  &lt;div&gt;\n    &lt;div class=&quot;form-group&quot;&gt;\n\t\t\t&lt;div class=&quot;row&quot;&gt;\n\t\t\t\t&lt;label class=&quot;col-lg-3 control-label text-right&quot; for=&quot;demo_search_customer&quot;&gt;\n          {{ &#039;Search customer&#039;|trans({}, &#039;Modules.Wkjsrouting.Admin&#039;) }}\n\t\t\t\t&lt;\/label&gt;\n\t\t\t\t&lt;div class=&quot;col-lg-6&quot;&gt;\n          &lt;div class=&quot;input-group&quot;&gt;\n            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;demo_search_customer&quot;&gt;\n            &lt;div class=&quot;input-group-addon&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot; id=&quot;demo_search_customer_btn&quot;&gt; {{ &#039;Search&#039;|trans({}, &#039;Modules.Wkjsrouting.Admin&#039;) }}&lt;\/button&gt;&lt;\/div&gt;\n          &lt;\/div&gt;\n\t\t\t\t&lt;\/div&gt;\n\t\t\t&lt;\/div&gt;\n\t\t&lt;\/div&gt;\n  &lt;\/div&gt;\n  &lt;div id=&quot;info-block&quot; class=&quot;d-none&quot;&gt;&lt;\/div&gt;\n  &lt;div id=&quot;customers-results&quot; class=&quot;d-none&quot;&gt;\n    &lt;table class=&quot;table table-striped&quot;&gt;\n      &lt;thead&gt;\n        &lt;tr&gt;\n          &lt;th&gt;{{ &#039;Email&#039;|trans({}, &#039;Modules.Wkjsrouting.Admin&#039;) }}&lt;\/th&gt;\n          &lt;th&gt;{{ &#039;Full Name&#039;|trans({}, &#039;Modules.Wkjsrouting.Admin&#039;) }}&lt;\/th&gt;\n        &lt;\/tr&gt;\n      &lt;\/thead&gt;\n      &lt;tbody&gt;\n      &lt;\/tbody&gt;\n    &lt;\/table&gt;\n  &lt;\/div&gt;\n{% endblock %}\n\n{% block javascripts %}\n  {{ parent() }}\n  &lt;script src=&quot;{{ asset(&#039;..\/modules\/wkjsrouting\/views\/js\/admin.js&#039;) }}&quot;&gt;&lt;\/script&gt;\n{% endblock %}<\/pre>\n\n\n\n<p><strong>Step 6: JS file for routing<\/strong><\/p>\n\n\n\n<p>This file is responsible to use the PrestaShop JS component<\/p>\n\n\n\n<p>Path: wkjsrouting\/views\/js\/admin.js<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$(() =&gt; {\n    \/\/ initialize the Router component in PS 1.7.8+ \n    if (typeof window.prestashop.component !== &#039;undefined&#039;) { window.prestashop.component.initComponents(&#091;&#039;Router&#039;]); }\n\n    \/\/ initiate the search on button click\n    $(document).on(&#039;click&#039;, &#039;#demo_search_customer_btn&#039;, () =&gt; search($(&#039;#demo_search_customer&#039;).val()));\n\n    \/**\n     * Performs ajax request to search for customers by search phrase\n     *\n     * @param searchPhrase\n     *\/\n    function search(searchPhrase) {\n        var route;\n        var getParams = { &#039;customer_search&#039;: searchPhrase };\n\n        if (typeof window.prestashop.component !== &#039;undefined&#039;) {\n            \/\/ use the router component to generate the existing route in PS 1.7.8+\n            route = window.prestashop.instance.router.generate(&#039;admin_customers_search&#039;);\n        } else {\n            \/\/ use pure JS functions if PS search route component is unavailable\n            const locationSearch = new URLSearchParams(window.location.search);\n            const locationPathname = window.location.pathname.split(&#039;\/&#039;);\n\n            for (const param of locationSearch) {\n                if (param&#091;0] === &#039;_token&#039;) getParams&#091;param&#091;0]] = param&#091;1];\n            }\n            route = `${locationPathname&#091;0]}\/${locationPathname&#091;1]}\/sell\/customers\/search`;\n        }\n\n        \/\/ use the ajax request to get customers\n        $.get(route, getParams\n            \/\/ render the customers\n        ).then((data) =&gt; renderResults(data));\n    }\n\n    \/**\n     * Renders the results block\n     *\n     * @param {Object} data\n     *\/\n    function renderResults(data) {\n        var $infoBlock = $(&#039;#info-block&#039;)\n        $infoBlock.addClass(&#039;d-none&#039;).empty();\n        var $resultsBlock = $(&#039;#customers-results&#039;);\n        var $resultsBody = $(&#039;#customers-results tbody&#039;);\n\n        if (data.found === false) {\n            $infoBlock.text(&#039;No customers found&#039;).removeClass(&#039;d-none&#039;);\n            $resultsBlock.addClass(&#039;d-none&#039;);\n            $resultsBody.empty();\n\n            return;\n        }\n\n        $resultsBlock.removeClass(&#039;d-none&#039;);\n        $resultsBody.empty();\n\n        for (const id in data.customers) {\n            const customer = data.customers&#091;id];\n            $resultsBody.append(`&lt;tr&gt;&lt;td&gt;${customer.email}&lt;\/td&gt;&lt;td&gt;${customer.firstname} ${customer.lastname}&lt;\/td&gt;&lt;\/tr&gt;`);\n        }\n    }\n});<\/pre>\n\n\n\n<p><strong>Step 7: Create a composer.json file to install the dependency<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{\n    &quot;name&quot;: &quot;prestashop\/wkjsrouting&quot;,\n    &quot;description&quot;: &quot;Demo Module&quot;,\n    &quot;license&quot;: &quot;AFL-3.0&quot;,\n    &quot;authors&quot;: &#091;{\n            &quot;name&quot;: &quot;Webkul&quot;\n        },\n        {\n            &quot;name&quot;: &quot;dev&quot;\n        }\n    ],\n    &quot;autoload&quot;: {\n        &quot;psr-4&quot;: {\n            &quot;PrestaShop\\\\Module\\\\WkJsRouting\\\\&quot;: &quot;src\/&quot;\n        },\n        &quot;config&quot;: {\n            &quot;prepend-autoloader&quot;: false\n        },\n        &quot;type&quot;: &quot;prestashop-module&quot;\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 8:<\/strong> <strong>Installation<\/strong><\/p>\n\n\n\n<p>Copy created a module on the modules directory of PrestaShop and run the composer command&nbsp;<strong>composer install<\/strong>&nbsp;to install all dependencies. The complete module folder structure is attached in the screenshot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\" alt=\"folder_structure\" class=\"wp-image-389104\" width=\"303\" height=\"473\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png 279w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure-192x300.png 192w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure-160x249.png 160w\" sizes=\"(max-width: 303px) 100vw, 303px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>After installing the module, click on configure button, and you will able to see the search page and search customers by name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output-1200x619.png\" alt=\"output\" class=\"wp-image-389105\" width=\"816\" height=\"420\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output-1200x619.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output-300x155.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output-250x129.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output-768x396.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/output.png 1294w\" sizes=\"(max-width: 816px) 100vw, 816px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/routing_results.gif\" alt=\"routing_results\" class=\"wp-image-389106\" width=\"823\" height=\"425\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>That\u2019s all about this blog.<\/p>\n\n\n\n<p>If any issues or doubts please feel free to mention them in the comment section.<\/p>\n\n\n\n<p>I would be happy to help.<\/p>\n\n\n\n<p>Also, you can explore our&nbsp;<a href=\"https:\/\/webkul.com\/prestashop-development\/\">PrestaShop Development Services<\/a>&nbsp;&amp; a large range of quality&nbsp;<a href=\"https:\/\/store.webkul.com\/PrestaShop-Extensions.html\">PrestaShop Modules<\/a>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will learn how to use the Javascript routing component in the PrestaShop back office. Since the 1.7.8.0 version, you can use components without importing them. window.prestashop.component the object is used for this purpose.These are some rules to understand the JS component i) Reusable components in BO will be available globally through <a href=\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":388,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[209,1],"tags":[2065,4126,14458,2710],"class_list":["post-389095","post","type-post","status-publish","format-standard","hentry","category-prestashop","category-uncategorized","tag-prestashop","tag-prestashop-1-7","tag-prestashop-8","tag-symfony"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use JS routing component in PrestaShop Backoffice - 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\/how-to-use-js-routing-component-in-prestashop-backoffice\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use JS routing component in PrestaShop Backoffice - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In this blog, we will learn how to use the Javascript routing component in the PrestaShop back office. Since the 1.7.8.0 version, you can use components without importing them. window.prestashop.component the object is used for this purpose.These are some rules to understand the JS component i) Reusable components in BO will be available globally through [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\" \/>\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=\"2023-06-30T12:13:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-30T12:13:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\" \/>\n<meta name=\"author\" content=\"Amit Kumar Tiwari\" \/>\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=\"Amit Kumar Tiwari\" \/>\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\/how-to-use-js-routing-component-in-prestashop-backoffice\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\"},\"author\":{\"name\":\"Amit Kumar Tiwari\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/d9ce9e306c32df23a286ed9b5eb81257\"},\"headline\":\"How to use JS routing component in PrestaShop Backoffice\",\"datePublished\":\"2023-06-30T12:13:02+00:00\",\"dateModified\":\"2023-06-30T12:13:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\"},\"wordCount\":411,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\",\"keywords\":[\"prestashop\",\"Prestashop 1.7\",\"Prestashop 8\",\"symfony\"],\"articleSection\":[\"prestashop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\",\"name\":\"How to use JS routing component in PrestaShop Backoffice - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\",\"datePublished\":\"2023-06-30T12:13:02+00:00\",\"dateModified\":\"2023-06-30T12:13:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png\",\"width\":279,\"height\":435,\"caption\":\"folder_structure\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use JS routing component in PrestaShop Backoffice\"}]},{\"@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\/d9ce9e306c32df23a286ed9b5eb81257\",\"name\":\"Amit Kumar Tiwari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0bfab402e3d85cb3f1ed4fbac60ad1c4532edd47917a00da0f77d94c75b54f7d?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\/0bfab402e3d85cb3f1ed4fbac60ad1c4532edd47917a00da0f77d94c75b54f7d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Amit Kumar Tiwari\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/amitkr-tiwari139\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use JS routing component in PrestaShop Backoffice - 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\/how-to-use-js-routing-component-in-prestashop-backoffice\/","og_locale":"en_US","og_type":"article","og_title":"How to use JS routing component in PrestaShop Backoffice - Webkul Blog","og_description":"In this blog, we will learn how to use the Javascript routing component in the PrestaShop back office. Since the 1.7.8.0 version, you can use components without importing them. window.prestashop.component the object is used for this purpose.These are some rules to understand the JS component i) Reusable components in BO will be available globally through [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-06-30T12:13:02+00:00","article_modified_time":"2023-06-30T12:13:09+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png","type":"","width":"","height":""}],"author":"Amit Kumar Tiwari","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Amit Kumar Tiwari","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/"},"author":{"name":"Amit Kumar Tiwari","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/d9ce9e306c32df23a286ed9b5eb81257"},"headline":"How to use JS routing component in PrestaShop Backoffice","datePublished":"2023-06-30T12:13:02+00:00","dateModified":"2023-06-30T12:13:09+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/"},"wordCount":411,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png","keywords":["prestashop","Prestashop 1.7","Prestashop 8","symfony"],"articleSection":["prestashop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/","url":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/","name":"How to use JS routing component in PrestaShop Backoffice - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png","datePublished":"2023-06-30T12:13:02+00:00","dateModified":"2023-06-30T12:13:09+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/folder_structure.png","width":279,"height":435,"caption":"folder_structure"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-use-js-routing-component-in-prestashop-backoffice\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use JS routing component in PrestaShop Backoffice"}]},{"@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\/d9ce9e306c32df23a286ed9b5eb81257","name":"Amit Kumar Tiwari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0bfab402e3d85cb3f1ed4fbac60ad1c4532edd47917a00da0f77d94c75b54f7d?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\/0bfab402e3d85cb3f1ed4fbac60ad1c4532edd47917a00da0f77d94c75b54f7d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Amit Kumar Tiwari"},"url":"https:\/\/webkul.com\/blog\/author\/amitkr-tiwari139\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/389095","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\/388"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=389095"}],"version-history":[{"count":18,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/389095\/revisions"}],"predecessor-version":[{"id":389231,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/389095\/revisions\/389231"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=389095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=389095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=389095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}