{"id":260907,"date":"2020-07-25T15:23:29","date_gmt":"2020-07-25T15:23:29","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=260907"},"modified":"2021-12-30T09:37:42","modified_gmt":"2021-12-30T09:37:42","slug":"how-to-add-entity-in-the-administration-at-the-shopware","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/","title":{"rendered":"How to add entity in the administration at the Shopware"},"content":{"rendered":"\n<p>In this blog, you are going to learn \u201cHow to add entity in the administration at Shopware.\u201d<br>I hope you know the directory structure of&nbsp;<a href=\"https:\/\/webkul.com\/blog\/create-product-and-product-variant-in-shopware-6\/\">Shopware<\/a>&nbsp;6 plugin, if you don\u2019t know, see here-&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/webkul.com\/blog\/create-product-and-product-variant-in-shopware-6\/\" target=\"_blank\">https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/directory-structure<\/a>.<\/p>\n\n\n\n<p>There are two different ways of how the global search works:<br>1 &#8211; Global search without type specification<br>2 -Typed global search<br>The API use is differs and displayed in a different way.<\/p>\n\n\n\n<p>The typed global search needs an instance of the JavaScript class ApiService with the key of the entity in the camel case suffixed with Service. E.g. The service key is testService when requesting service for a test. entity definition gets automatically an instance in the injection container but can be overridden so there is no additional work needed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add the search tag<\/h4>\n\n\n\n<p>The search tag displays the entity type that uses in the type search and is a clickable button to switch from the untype to the typed search. A service decorator use for adding the tag in order to add a type to the search type service.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">const { Application } = Shopware;\n\nApplication.addServiceProviderDecorator(&#039;searchTypeService&#039;, searchTypeService =&gt; {\n    searchTypeService.upsertType(&#039;test&#039;, {\n        entityName: &#039;test&#039;,\n        entityService: &#039;testService&#039;,\n        placeholderSnippet: &#039;test.general.placeholderSearchBar&#039;,\n        listingRoute: &#039;test.index&#039;\n    });\n\n    return searchTypeService;\n});<\/pre>\n\n\n\n<p><mark>Both key and entityName use as the same to change existing types.<\/mark> <mark>The entity service use for the typed search.<\/mark> This service can override with an own implementation for customization. The placeholder snippet is a translation key when no search term entered. The listing route uses to show a link to continue the search in the module-specific listing view.<\/p>\n\n\n\n<p>By default, the search bar does not know how to display the result items so a current search request will not show any result.<br><code>sw-search-bar-item.html.twig<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{% block sw_search_bar_item_cms_page %}\n    {% parent %}\n\n    &lt;router-link v-else-if=&quot;type === &#039;test&#039;&quot;\n                 v-bind:to=&quot;{ name: &#039;test.detail&#039;, params: { id: item.id } }&quot;\n                 ref=&quot;routerLink&quot;\n                 class=&quot;sw-search-bar-item__link&quot;&gt;\n        {% block sw_search_bar_item_test_label %}\n            &lt;span class=&quot;sw-search-bar-item__label&quot;&gt;\n                &lt;sw-highlight-text v-bind:searchTerm=&quot;searchTerm&quot;\n                                   v-bind:text=&quot;item.name&quot;&gt;\n                &lt;\/sw-highlight-text&gt;\n            &lt;\/span&gt;\n        {% endblock %}\n    &lt;\/router-link&gt;\n{% endblock %}<\/pre>\n\n\n\n<p><strong>index.js<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import template from &#039;.\/sw-search-bar-item.html.twig&#039;;\nShopware.Component.override(&#039;sw-search-bar-item&#039;, {\ntemplate\n})<\/pre>\n\n\n\n<p>The sw_search_bar_item_cms_page block use as it is the last block but it is not important which Shopware type is extended as long as the Vue else-if structure is kept working.<\/p>\n\n\n\n<p>By default, the search bar tries to resolve to the registered listing route. <br><code>sw-search-more-results.html.twig<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{% block sw_search_more_results %}\n    &lt;template v-if=&quot;result.entity === &#039;test&#039;&quot;&gt;\n        &lt;a :href=&quot;&#039;https:\/\/webkul.com\/?q=&#039; + searchTerm&quot;\n           class=&quot;sw-search-bar-item__link&quot;\n           target=&quot;_blank&quot;&gt;\n            look it\n        &lt;\/a&gt;\n        in the ERP instead.\n    &lt;\/template&gt;\n    &lt;template v-else&gt;\n        {% parent %}\n    &lt;\/template&gt;\n{% endblock %}<\/pre>\n\n\n\n<p><strong>index.js<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import template from &#039;.\/sw-search-more-result.html.twig&#039;;\nShopware.Component.override(&#039;sw-search-more-result&#039;, {\ntemplate\n})<\/pre>\n\n\n\n<p>I hope it will help you. Thanks for reading. Happy Coding \ud83d\ude42<br>Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, you are going to learn \u201cHow to add entity in the administration at Shopware.\u201dI hope you know the directory structure of&nbsp;Shopware&nbsp;6 plugin, if you don\u2019t know, see here-&nbsp;https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/directory-structure. There are two different ways of how the global search works:1 &#8211; Global search without type specification2 -Typed global searchThe API use is differs <a href=\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":284,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9568],"tags":[],"class_list":["post-260907","post","type-post","status-publish","format-standard","hentry","category-shopware"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to add entity in the administration at the Shopware - Webkul Blog<\/title>\n<meta name=\"description\" content=\"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.\" \/>\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-add-entity-in-the-administration-at-the-shopware\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add entity in the administration at the Shopware - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\" \/>\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=\"2020-07-25T15:23:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-30T09:37:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Diwakar Rana\" \/>\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=\"Diwakar Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 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-add-entity-in-the-administration-at-the-shopware\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\"},\"author\":{\"name\":\"Diwakar Rana\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/4b025fe4ecbc5c0378cd13bb70da654f\"},\"headline\":\"How to add entity in the administration at the Shopware\",\"datePublished\":\"2020-07-25T15:23:29+00:00\",\"dateModified\":\"2021-12-30T09:37:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\"},\"wordCount\":342,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"Shopware\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\",\"name\":\"How to add entity in the administration at the Shopware - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2020-07-25T15:23:29+00:00\",\"dateModified\":\"2021-12-30T09:37:42+00:00\",\"description\":\"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to add entity in the administration at the Shopware\"}]},{\"@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\/4b025fe4ecbc5c0378cd13bb70da654f\",\"name\":\"Diwakar Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?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\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Diwakar Rana\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/diwakar-rana829\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to add entity in the administration at the Shopware - Webkul Blog","description":"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.","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-add-entity-in-the-administration-at-the-shopware\/","og_locale":"en_US","og_type":"article","og_title":"How to add entity in the administration at the Shopware - Webkul Blog","og_description":"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.","og_url":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2020-07-25T15:23:29+00:00","article_modified_time":"2021-12-30T09:37:42+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Diwakar Rana","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Diwakar Rana","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/"},"author":{"name":"Diwakar Rana","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/4b025fe4ecbc5c0378cd13bb70da654f"},"headline":"How to add entity in the administration at the Shopware","datePublished":"2020-07-25T15:23:29+00:00","dateModified":"2021-12-30T09:37:42+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/"},"wordCount":342,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["Shopware"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/","url":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/","name":"How to add entity in the administration at the Shopware - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2020-07-25T15:23:29+00:00","dateModified":"2021-12-30T09:37:42+00:00","description":"The typed global search needs an instance of the Js class ApiService with the key of the entity in the camel case suffixed with Service.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-add-entity-in-the-administration-at-the-shopware\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to add entity in the administration at the Shopware"}]},{"@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\/4b025fe4ecbc5c0378cd13bb70da654f","name":"Diwakar Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?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\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Diwakar Rana"},"url":"https:\/\/webkul.com\/blog\/author\/diwakar-rana829\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/260907","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\/284"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=260907"}],"version-history":[{"count":8,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/260907\/revisions"}],"predecessor-version":[{"id":260964,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/260907\/revisions\/260964"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=260907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=260907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=260907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}