{"id":16335,"date":"2018-07-24T14:20:06","date_gmt":"2018-07-24T12:20:06","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=16335"},"modified":"2021-02-18T13:58:07","modified_gmt":"2021-02-18T11:58:07","slug":"how-to-use-data-related-classes-repositories-and-data-api-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html","title":{"rendered":"How to Use Data-related Classes, Repositories and Data API in Magento 2"},"content":{"rendered":"\n<p><span style=\"color: #000000\">This is Part 1 of the series of articles dedicated to using data-related classes, repositories and data API in Magento 2. Today we will touch upon two questions: obtaining an object or set of objects from the database using a repository and&nbsp;configuring and creating a SearchCriteria instance using the builder.<\/span><\/p>\n<p><!--more--><\/p>\n<h2><strong><span style=\"color: #000000\">Obtaining an object or set of objects from the database using a repository<\/span><\/strong><\/h2>\n<p>To work with collections in Magento 2, you can use a repository that implements the same repository pattern. The Repository pattern allows working with collections as entities, regardless of their storage location (storage or caching are implementation details). The pattern itself is located between the Domain and the Service Level.<\/p>\n<p>In Magento 2, there are usually 5 basic functions of the repository: save, getById, getList, delete, deleteById. But each Repository implementation in Magento has its own interface and these functions are not always implemented in it. For example, in <em>Magento\\Quote\\Api\\GuestCartTotalRepositoryInterface<\/em>, only the <strong>get($cartId)<\/strong> method is implemented. Therefore, it is better to pay attention to the implementation of a particular Repository class.<\/p>\n<p>Let&rsquo;s take a look at the Repository using the example of <em>\\Magento\\Catalog\\Api\\ProductRepositoryInterface<\/em> and its implementation <em>\\Magento\\Catalog\\Model\\ProductRepository.<\/em><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nnamespace Magento\\Catalog\\Api;\r\ninterface ProductRepositoryInterface\r\n{\r\n&nbsp;&nbsp;&nbsp;public function save(\\Magento\\Catalog\\Api\\Data\\ProductInterface $product, $saveOptions = false);\r\n&nbsp;&nbsp;&nbsp;public function get($sku, $editMode = false, $storeId = null, $forceReload = false);\r\n&nbsp;&nbsp;&nbsp;public function getById($productId, $editMode = false, $storeId = null, $forceReload = false);\r\n&nbsp;&nbsp;&nbsp;public function delete(\\Magento\\Catalog\\Api\\Data\\ProductInterface $product);\r\n&nbsp;&nbsp;&nbsp;public function deleteById($sku);\r\n&nbsp;&nbsp;&nbsp;public function getList(\\Magento\\Framework\\Api\\SearchCriteriaInterface $searchCriteria);\r\n}<\/pre>\n<p>Here all 5 basic functions for working with Repository are implemented. Meanwhile, the main class when working with a product is <em>\\Magento\\Catalog\\Api\\Data\\ProductInterface<\/em>, which allows you to save all products inherited from this class, regardless of their type.<\/p>\n<p>Let&rsquo;s look at the implementation of the <strong>getById<\/strong> method:<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n&hellip;\r\nprotected $productRepository;\r\npublic function __construct(\r\n&hellip;\r\n\\Magento\\Catalog\\Api\\ProductRepositoryInterface $productRepository)\r\n{\r\n$this-&gt;productRepository = $productRepository;\r\n}\r\n...\r\npublic function someMethod() {\r\n$product = $this-&gt;productRepository-&gt;getById(1);\r\nreturn $product-&gt;getSku();\r\n}\r\n&hellip;\r\n...\r\npublic function someDeleteMethod() {\r\n$this-&gt;productRepository-&gt;deleteById(1);\r\n}\r\n&hellip;<\/pre>\n<p>Here we implement the work with <em>ProductRepository<\/em>, extracting the object with id 1 and returning its SKU. Similarly, the <strong>deleteById<\/strong> method will be implemented. In the constructor, as you can see, we create <em>\\Magento\\Catalog\\Api\\ProductRepositoryInterface<\/em>, and not <em>\\Magento\\Catalog\\Model\\ProductRepository<\/em> itself. These dependencies are described in the <strong>di.xml<\/strong> file. For example, for the current class, the dependency is described in <em>vendor\/magento\/module-catalog\/etc\/di.xml<\/em> and looks like this:<\/p>\n<pre class=\"lang:php decode:true\">&lt;preference for=\"Magento\\Catalog\\Api\\ProductRepositoryInterface\" type=\"Magento\\Catalog\\Model\\ProductRepository\" \/&gt;\r\nHere is the implementation of the save method:\r\n...\r\npublic function someMethod() {\r\n$product = $this-&gt;productRepository-&gt;getById(1);\r\n$product-&gt;setSku(&lsquo;test-sku-1&rsquo;);\r\n$this-&gt;productRepository-&gt;save($product);\r\n}\r\n&hellip;\r\n...\r\npublic function someDeleteMethod() {\r\n$product = $this-&gt;productRepository-&gt;getById(1);\r\n$this-&gt;productRepository-&gt;delete($product);\r\n}\r\n&hellip;<\/pre>\n<p>Here we have changed the SKU of the product and saved it using the save repository method. The <strong>delete<\/strong> method works similarly (but with the opposite result).<\/p>\n<h2><strong><span style=\"color: #000000\">Configuring and creating a SearchCriteria instance using the builder<\/span><\/strong><\/h2>\n<p>The <strong>getList<\/strong> method, in this context, is implemented using <em>SearchCriteriaInterface<\/em>. This interface implements the conditions for queries (for example, in MySQL this is <strong>where<\/strong> in the query). All conditions are divided into <strong>Filter<\/strong> and <strong>FilterGroup<\/strong>.<\/p>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image21.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-16339 size-full\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/image21.png\" alt=\"Filter and FilterGroup\" width=\"577\" height=\"132\" title=\"How to Use Data-related Classes, Repositories and Data API in Magento 2\"><\/a><\/p>\n<p>We implement the abovementioned conditions using SearchCriteria:<\/p>\n<pre class=\"lang:php decode:true\">public function someMethod() {\r\n$filter = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\Filter');\r\n$filter-&gt;setField(&lsquo;sku&rsquo;);\r\n$filter-&gt;setValue(&lsquo;test-%&rsquo;);\r\n$filter-&gt;setConditionType(&lsquo;like&rsquo;);\r\n$filter2 = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\Filter');\r\n$filter2-&gt;setField(&lsquo;sku&rsquo;);\r\n$filter2-&gt;setValue(&lsquo;%-product&rsquo;);\r\n$filter2-&gt;setConditionType(&lsquo;like&rsquo;);\r\n$filterGroup = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\Search\\FilterGroup');\r\n$filterGroup&gt;setFilters([$filter, $filter2]);\r\n$filter3 = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\Filter');\r\n$filter3-&gt;setField(&lsquo;price&rsquo;);\r\n$filter3-&gt;setValue(&lsquo;100&rsquo;);\r\n$filter3-&gt;setConditionType(&lsquo;eq&rsquo;);\r\n$filterGroup2 = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\Search\\FilterGroup');\r\n$filterGroup2&gt;setFilters([$filter3]);\r\n$searchCriteria- = $this-&gt;objectManager-&gt;create('Magento\\Framework\\Api\\SearchCriteriaInterface');\r\n$searchCriteria-&gt;setFilterGroups([$filterGroup, $filterGroup2]);\r\n$result = $this-&gt;productRepository&gt;getList($searchCriteria-);\r\nreturn $result-&gt;getItems();\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">This example returns an array of objects inherited from <em>\\Magento\\Catalog\\Api\\Data\\ProductInterface.<\/em><\/span><\/p>\n<p>This is the end of part 1 of the series dedicated to data-related classes, repositories and data API in Magento 2. The other parts are coming up soon, stay tuned.<\/p>\n\n","protected":false},"excerpt":{"rendered":"Data-related Classes, Repositories and Data API in Magento 2: Part 1","protected":false},"author":82,"featured_media":16340,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[491,389],"tags":[],"class_list":["post-16335","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento-2","category-magento2-development","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Obtaining an object or set of objects from the database using a repository. Configuring and creating a SearchCriteria instance using the builder.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#article\",\"name\":\"Data-related Classes, Repositories and Data API in Magento 2 | BelVG Blog\",\"headline\":\"How to Use Data-related Classes, Repositories and Data API in Magento 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/How-to-Use-Data-related-Classes-Repositories-and-Data-API-2.jpg\",\"width\":770,\"height\":433,\"caption\":\"Using Data-related Classes, Repositories and Data API. Part 1\"},\"datePublished\":\"2018-07-24T14:20:06+02:00\",\"dateModified\":\"2021-02-18T13:58:07+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage\"},\"articleSection\":\"Magento 2, Magento 2 Development, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#listItem\",\"name\":\"How to Use Data-related Classes, Repositories and Data API in Magento 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#listItem\",\"position\":3,\"name\":\"How to Use Data-related Classes, Repositories and Data API in Magento 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html\",\"name\":\"Data-related Classes, Repositories and Data API in Magento 2 | BelVG Blog\",\"description\":\"Obtaining an object or set of objects from the database using a repository. Configuring and creating a SearchCriteria instance using the builder.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/How-to-Use-Data-related-Classes-Repositories-and-Data-API-2.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html\\\/#mainImage\",\"width\":770,\"height\":433,\"caption\":\"Using Data-related Classes, Repositories and Data API. Part 1\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#mainImage\"},\"datePublished\":\"2018-07-24T14:20:06+02:00\",\"dateModified\":\"2021-02-18T13:58:07+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Data-related Classes, Repositories and Data API in Magento 2 | BelVG Blog","description":"Obtaining an object or set of objects from the database using a repository. Configuring and creating a SearchCriteria instance using the builder.","canonical_url":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#article","name":"Data-related Classes, Repositories and Data API in Magento 2 | BelVG Blog","headline":"How to Use Data-related Classes, Repositories and Data API in Magento 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/How-to-Use-Data-related-Classes-Repositories-and-Data-API-2.jpg","width":770,"height":433,"caption":"Using Data-related Classes, Repositories and Data API. Part 1"},"datePublished":"2018-07-24T14:20:06+02:00","dateModified":"2021-02-18T13:58:07+02:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage"},"articleSection":"Magento 2, Magento 2 Development, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#listItem","name":"How to Use Data-related Classes, Repositories and Data API in Magento 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#listItem","position":3,"name":"How to Use Data-related Classes, Repositories and Data API in Magento 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html","name":"Data-related Classes, Repositories and Data API in Magento 2 | BelVG Blog","description":"Obtaining an object or set of objects from the database using a repository. Configuring and creating a SearchCriteria instance using the builder.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/07\/How-to-Use-Data-related-Classes-Repositories-and-Data-API-2.jpg","@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html\/#mainImage","width":770,"height":433,"caption":"Using Data-related Classes, Repositories and Data API. Part 1"},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html#mainImage"},"datePublished":"2018-07-24T14:20:06+02:00","dateModified":"2021-02-18T13:58:07+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"16335","title":"Data-related Classes, Repositories and Data API in Magento 2 | #site_title","description":"Obtaining an object or set of objects from the database using a repository. Configuring and creating a SearchCriteria instance using the builder.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:06","updated":"2026-11-03 18:37:06"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to Use Data-related Classes, Repositories and Data API in Magento 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How to Use Data-related Classes, Repositories and Data API in Magento 2","link":"https:\/\/belvg.com\/blog\/how-to-use-data-related-classes-repositories-and-data-api-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=16335"}],"version-history":[{"count":-3,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/16335\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/16340"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=16335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=16335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=16335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}