{"id":336322,"date":"2022-07-07T09:36:17","date_gmt":"2022-07-07T09:36:17","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=336322"},"modified":"2022-08-08T11:08:46","modified_gmt":"2022-08-08T11:08:46","slug":"associations-in-prestashop-webservice","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/","title":{"rendered":"Associations in PrestaShop 1.7 Webservice"},"content":{"rendered":"\n<p>In this blog, we are going to learn how to create associations in the PrestaShop Webservice and get data from the association table.<\/p>\n\n\n\n<p>So let\u2019s understand how to achieve it:<\/p>\n\n\n\n<p>Sometimes, we need to give our module association table data in API then simply we will get it with the help of PrestaShop hook and some changes in our class file.<\/p>\n\n\n\n<p>In PrestaShop, we can add new resources using hook <strong>hookAddWebserviceResources<\/strong> and give permission to get data of these added resources from the PrestaShop Webservice section.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">public function hookAddWebserviceResources()\n{\n    $resources = array(\n        &#039;wk_supplier_purchase_order_manual&#039; =&gt; array(&#039;description&#039; =&gt; &#039;PO order manual&#039;, &#039;class&#039; =&gt; &#039;WkSupplierPurchaseOrderManual&#039;)\n    );\n    ksort($resources);\n    return $resources;\n}<\/pre>\n\n\n\n<p>Now we will go to the class file and define the value in the protected <strong>$webserviceParameters<\/strong> variable for associations.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">protected $webserviceParameters = array(\n    &#039;associations&#039; =&gt; array(\n        &#039;items&#039; =&gt; array(\n            &#039;resource&#039; =&gt; &#039;wk_supplier_purchase_order_detail_manual&#039;,\n            &#039;fields&#039; =&gt; array(\n                &#039;id_wk_supplier_purchase_order_manual&#039; =&gt; array(&#039;required&#039; =&gt; true),\n                &#039;quantity&#039; =&gt; array(&#039;required&#039; =&gt; true),\n                &#039;product_name&#039; =&gt; array(&#039;required&#039; =&gt; true),\n                &#039;supplier_code&#039; =&gt; array(&#039;required&#039; =&gt; true),\n            )\n        )\n    )\n);<\/pre>\n\n\n\n<p>In the above code, we have defined the association array and given the association table name as a resource and fields that we want from the association table.<\/p>\n\n\n\n<p>After doing the above changes, you will get the association table data in your API call.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"739\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png\" alt=\"association_in_webservice\" class=\"wp-image-342777\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-300x185.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-250x154.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-768x473.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice.png 1219w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>That\u2019s all about this blog. Hope it will help you.<\/p>\n\n\n\n<p>If you are facing any issues or doubts in the above process, please feel free to contact us through the comment section.<\/p>\n\n\n\n<p>We 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>For any doubt contact us at&nbsp;<a href=\"mailto:support@webkul.com\">support@webkul.com<\/a>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we are going to learn how to create associations in the PrestaShop Webservice and get data from the association table. So let\u2019s understand how to achieve it: Sometimes, we need to give our module association table data in API then simply we will get it with the help of PrestaShop hook and <a href=\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":416,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[209],"tags":[2065,294],"class_list":["post-336322","post","type-post","status-publish","format-standard","hentry","category-prestashop","tag-prestashop","tag-webservices"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Associations in PrestaShop 1.7 Webservice<\/title>\n<meta name=\"description\" content=\"Associations in PrestaShop 1.7 Webservice\" \/>\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\/associations-in-prestashop-webservice\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Associations in PrestaShop 1.7 Webservice\" \/>\n<meta property=\"og:description\" content=\"Associations in PrestaShop 1.7 Webservice\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\" \/>\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=\"2022-07-07T09:36:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-08T11:08:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png\" \/>\n<meta name=\"author\" content=\"Gajendra Singh\" \/>\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=\"Gajendra Singh\" \/>\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\/associations-in-prestashop-webservice\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\"},\"author\":{\"name\":\"Gajendra Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba72ea261f883808a566a3ab8b63dede\"},\"headline\":\"Associations in PrestaShop 1.7 Webservice\",\"datePublished\":\"2022-07-07T09:36:17+00:00\",\"dateModified\":\"2022-08-08T11:08:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\"},\"wordCount\":222,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png\",\"keywords\":[\"prestashop\",\"webservices\"],\"articleSection\":[\"prestashop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\",\"url\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\",\"name\":\"Associations in PrestaShop 1.7 Webservice\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png\",\"datePublished\":\"2022-07-07T09:36:17+00:00\",\"dateModified\":\"2022-08-08T11:08:46+00:00\",\"description\":\"Associations in PrestaShop 1.7 Webservice\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice.png\",\"width\":1219,\"height\":751,\"caption\":\"association_in_webservice\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Associations in PrestaShop 1.7 Webservice\"}]},{\"@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\/ba72ea261f883808a566a3ab8b63dede\",\"name\":\"Gajendra Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9d864b4124944a25bce60168e4d9520c03a18cdca40483dfbf0d9e46d2f0d32c?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\/9d864b4124944a25bce60168e4d9520c03a18cdca40483dfbf0d9e46d2f0d32c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Gajendra Singh\"},\"description\":\"Gajendra Singh, a PrestaShop Software Engineer, excels in Mobile App and Custom Extension Development. A tech-savvy expert in Docker and POS, he creates innovative solutions. Gajendra's skills ensure a seamless PrestaShop experience, catering to diverse needs.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/gajendra-singh681\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Associations in PrestaShop 1.7 Webservice","description":"Associations in PrestaShop 1.7 Webservice","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\/associations-in-prestashop-webservice\/","og_locale":"en_US","og_type":"article","og_title":"Associations in PrestaShop 1.7 Webservice","og_description":"Associations in PrestaShop 1.7 Webservice","og_url":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-07-07T09:36:17+00:00","article_modified_time":"2022-08-08T11:08:46+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png","type":"","width":"","height":""}],"author":"Gajendra Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Gajendra Singh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/"},"author":{"name":"Gajendra Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba72ea261f883808a566a3ab8b63dede"},"headline":"Associations in PrestaShop 1.7 Webservice","datePublished":"2022-07-07T09:36:17+00:00","dateModified":"2022-08-08T11:08:46+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/"},"wordCount":222,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png","keywords":["prestashop","webservices"],"articleSection":["prestashop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/","url":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/","name":"Associations in PrestaShop 1.7 Webservice","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice-1200x739.png","datePublished":"2022-07-07T09:36:17+00:00","dateModified":"2022-08-08T11:08:46+00:00","description":"Associations in PrestaShop 1.7 Webservice","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/association_in_webservice.png","width":1219,"height":751,"caption":"association_in_webservice"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/associations-in-prestashop-webservice\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Associations in PrestaShop 1.7 Webservice"}]},{"@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\/ba72ea261f883808a566a3ab8b63dede","name":"Gajendra Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9d864b4124944a25bce60168e4d9520c03a18cdca40483dfbf0d9e46d2f0d32c?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\/9d864b4124944a25bce60168e4d9520c03a18cdca40483dfbf0d9e46d2f0d32c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Gajendra Singh"},"description":"Gajendra Singh, a PrestaShop Software Engineer, excels in Mobile App and Custom Extension Development. A tech-savvy expert in Docker and POS, he creates innovative solutions. Gajendra's skills ensure a seamless PrestaShop experience, catering to diverse needs.","url":"https:\/\/webkul.com\/blog\/author\/gajendra-singh681\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/336322","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\/416"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=336322"}],"version-history":[{"count":24,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/336322\/revisions"}],"predecessor-version":[{"id":343006,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/336322\/revisions\/343006"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=336322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=336322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=336322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}