{"id":8608,"date":"2023-08-15T10:21:53","date_gmt":"2023-08-15T10:21:53","guid":{"rendered":"https:\/\/www.magetop.com\/blog\/?p=8608"},"modified":"2023-08-15T18:36:43","modified_gmt":"2023-08-15T18:36:43","slug":"using-sql-distinct-query-in-magento-2","status":"publish","type":"post","link":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/","title":{"rendered":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide"},"content":{"rendered":"\n<p>In Magento 2, SQL queries play a crucial role in retrieving and manipulating data from the database. One powerful feature of SQL is the Distinct keyword, which allows you to retrieve unique values from a column or a combination of columns. In this step-by-step guide, we will explore how to effectively use the SQL Distinct query in Magento 2 to filter and retrieve distinct data. Let&#8217;s dive in!<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the SQL Distinct Query<\/h2>\n\n\n\n<p><strong>What is the SQL Distinct Query?<\/strong><\/p>\n\n\n\n<p>The SQL Distinct query is used to retrieve unique values from a specific column or combination of columns in a database table. It filters out duplicate records and returns a result set containing only distinct values. The DISTINCT keyword is added to the SELECT statement to indicate that only unique values should be included in the query result.<\/p>\n\n\n\n<p><strong>How does the SQL Distinct Query work?<\/strong><\/p>\n\n\n\n<p>When you execute an SQL Distinct query, the database engine scans the specified column(s) in the table and identifies unique values. It compares each value with the existing result set and includes only those values that are not already present. This process ensures that the returned result set contains only distinct values for the specified column(s).<\/p>\n\n\n\n<p><strong>Advantages and use cases of using the SQL Distinct Query in Magento 2<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Eliminating Duplicate Entries: The SQL Distinct query is useful in scenarios where you want to remove duplicate records from your query results. In Magento 2, this can be helpful when retrieving unique customer emails, product names, or IDs. Also when there are duplicate values you will most likely get an error:&nbsp;same id &#8220;*&#8221; already exist.<\/li>\n\n\n\n<li>Generating Unique Reports: By using the SQL Distinct query, you can obtain unique data for generating reports or performing data analysis. For example, you can retrieve a distinct list of customers who have made purchases within a specific time period.<\/li>\n\n\n\n<li>Filtering and Segmenting Data: The Distinct query allows you to filter and segment your data based on unique values. This can be beneficial when you need to identify unique customer groups, product attributes, or any other distinct data points in your Magento 2 store.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Ways to Use the SQL Distinct Query in Magento 2<\/h2>\n\n\n\n<p><strong>1.&nbsp;Using Direct SQL Queries in Magento 2:<\/strong><br>You can write direct SQL queries in Magento 2 and use the DISTINCT keyword to filter out duplicate values. For example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; title: ; notranslate\" title=\"\">\n$connection = $this-&gt;resource-&gt;getConnection();\n$tableName = $this-&gt;resource-&gt;getTableName('your_table');\n\n$query = $connection-&gt;select()-&gt;distinct()-&gt;from($tableName, 'your_column');\n$results = $connection-&gt;fetchAll($query);\n<\/pre><\/div>\n\n\n<p><strong>2. Using the&nbsp;distinct()&nbsp;Function in Collection:<\/strong><\/p>\n\n\n\n<p>In Magento 2, you can also use the&nbsp;<code>distinct()<\/code> method on a Collection to retrieve unique records based on a specific column. For example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$collection = $this-&gt;yourModelFactory-&gt;create()-&gt;getCollection();\n\n\/\/ Applying filters or additional conditions to the collection\n$collection-&gt;addFieldToSelect('customer_email')\n    -&gt;addFieldToFilter('status', &#x5B;'eq' =&gt; 'complete'])\n    -&gt;addFieldToFilter('created_at', &#x5B;'from' =&gt; '2023-01-01', 'to' =&gt; '2023-12-31']);\n\n\/\/ Using distinct(true) to retrieve unique values of the 'customer_email' field in the collection\n$collection-&gt;distinct(true);\n\n\/\/ Iterating through the orders in the collection and displaying customer emails\nforeach ($collection as $order) {\n    echo $order-&gt;getCustomerEmail() . &quot;&lt;br&gt;&quot;;\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In conclusion, this article has provided a comprehensive step-by-step guide on using the SQL Distinct query in Magento 2. We have explored the concept of Distinct and its significance in retrieving unique values from a <a href=\"https:\/\/www.magetop.com\/blog\/magento-2-how-to-create-database-table\/\" target=\"_blank\" rel=\"noreferrer noopener\">database table<\/a>.<\/p>\n\n\n\n<p>Through the guide, we have covered various scenarios where the Distinct query can be applied effectively, such as filtering duplicate entries, generating unique product lists, and obtaining distinct attribute values. By following the outlined steps, users can leverage the power of SQL Distinct to enhance their data retrieval and analysis capabilities within the Magento 2 platform.<\/p>\n\n\n\n<p>However, it also has potential limitations and considerations that need to be taken into account. One such consideration is its impact on query performance. When using Distinct, the database engine needs to perform additional operations to identify and eliminate duplicate values, which can result in slower query execution times, especially when dealing with large datasets.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this step-by-step guide, we will explore how to effectively use the SQL Distinct query in Magento 2 to filter and retrieve distinct data. Let&#8217;s dive in!<\/p>\n","protected":false},"author":108,"featured_media":8628,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[107,2081],"class_list":["post-8608","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento-2-tutorials","tag-magento-2-tutorials","tag-using-sql-distinct-query-in-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using SQL Distinct Query in Magento 2: A Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide\" \/>\n<meta property=\"og:description\" content=\"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Magetop Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/MagetopStore\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-15T10:21:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-15T18:36:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"1019\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Callula Huy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MagetopStore\" \/>\n<meta name=\"twitter:site\" content=\"@MagetopStore\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Callula Huy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\"},\"author\":{\"name\":\"Callula Huy\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/a2bf0aa38cec01bc41197b9ec4b3e8c9\"},\"headline\":\"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide\",\"datePublished\":\"2023-08-15T10:21:53+00:00\",\"dateModified\":\"2023-08-15T18:36:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\"},\"wordCount\":573,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1\",\"keywords\":[\"magento 2 tutorials\",\"Using SQL Distinct Query in Magento 2\"],\"articleSection\":[\"Magento 2 Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\",\"url\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\",\"name\":\"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1\",\"datePublished\":\"2023-08-15T10:21:53+00:00\",\"dateModified\":\"2023-08-15T18:36:43+00:00\",\"description\":\"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1\",\"width\":1400,\"height\":1019,\"caption\":\"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.magetop.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#website\",\"url\":\"https:\/\/www.magetop.com\/blog\/\",\"name\":\"Magetop Blog\",\"description\":\"Exploring Magento Tips, Tricks, and Trends\",\"publisher\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.magetop.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#organization\",\"name\":\"Magetop.com\",\"url\":\"https:\/\/www.magetop.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/11\/logo.png?fit=475%2C475&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/11\/logo.png?fit=475%2C475&ssl=1\",\"width\":475,\"height\":475,\"caption\":\"Magetop.com\"},\"image\":{\"@id\":\"https:\/\/www.magetop.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/MagetopStore\",\"https:\/\/x.com\/MagetopStore\",\"https:\/\/www.linkedin.com\/company\/magetop\",\"https:\/\/www.pinterest.com\/magetop\",\"https:\/\/www.youtube.com\/channel\/UCXoiJsz88OfPmwa8QpUkwOA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/a2bf0aa38cec01bc41197b9ec4b3e8c9\",\"name\":\"Callula Huy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/321e837578b99a75c9d7f5c884e62e11b3b6df2b5934726e98fd365f580393c7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/321e837578b99a75c9d7f5c884e62e11b3b6df2b5934726e98fd365f580393c7?s=96&d=mm&r=g\",\"caption\":\"Callula Huy\"},\"description\":\"Callula is the Marketing Executive at Magetop. With more than 5 years of copywriting under his belt, Callula is into creating valuable content that is straight to the point. Life student. Workaholic. Foreign languages and traveling aficionado.\",\"sameAs\":[\"http:\/\/magetop.com\"],\"url\":\"https:\/\/www.magetop.com\/blog\/author\/callula-huy\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide","description":"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.","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:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide","og_description":"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.","og_url":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/","og_site_name":"Magetop Blog","article_publisher":"https:\/\/www.facebook.com\/MagetopStore","article_published_time":"2023-08-15T10:21:53+00:00","article_modified_time":"2023-08-15T18:36:43+00:00","og_image":[{"width":1400,"height":1019,"url":"https:\/\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png","type":"image\/png"}],"author":"Callula Huy","twitter_card":"summary_large_image","twitter_creator":"@MagetopStore","twitter_site":"@MagetopStore","twitter_misc":{"Written by":"Callula Huy","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/"},"author":{"name":"Callula Huy","@id":"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/a2bf0aa38cec01bc41197b9ec4b3e8c9"},"headline":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide","datePublished":"2023-08-15T10:21:53+00:00","dateModified":"2023-08-15T18:36:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/"},"wordCount":573,"commentCount":0,"publisher":{"@id":"https:\/\/www.magetop.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1","keywords":["magento 2 tutorials","Using SQL Distinct Query in Magento 2"],"articleSection":["Magento 2 Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/","url":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/","name":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide","isPartOf":{"@id":"https:\/\/www.magetop.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1","datePublished":"2023-08-15T10:21:53+00:00","dateModified":"2023-08-15T18:36:43+00:00","description":"In this step-by-step guide, we will explore how to effectively use the SQL DISTINCT query in Magento 2 to filter and retrieve distinct data.","breadcrumb":{"@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#primaryimage","url":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1","width":1400,"height":1019,"caption":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide"},{"@type":"BreadcrumbList","@id":"https:\/\/www.magetop.com\/blog\/using-sql-distinct-query-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.magetop.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using SQL Distinct Query in Magento 2: A Step-by-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.magetop.com\/blog\/#website","url":"https:\/\/www.magetop.com\/blog\/","name":"Magetop Blog","description":"Exploring Magento Tips, Tricks, and Trends","publisher":{"@id":"https:\/\/www.magetop.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.magetop.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.magetop.com\/blog\/#organization","name":"Magetop.com","url":"https:\/\/www.magetop.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.magetop.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/11\/logo.png?fit=475%2C475&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/11\/logo.png?fit=475%2C475&ssl=1","width":475,"height":475,"caption":"Magetop.com"},"image":{"@id":"https:\/\/www.magetop.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/MagetopStore","https:\/\/x.com\/MagetopStore","https:\/\/www.linkedin.com\/company\/magetop","https:\/\/www.pinterest.com\/magetop","https:\/\/www.youtube.com\/channel\/UCXoiJsz88OfPmwa8QpUkwOA"]},{"@type":"Person","@id":"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/a2bf0aa38cec01bc41197b9ec4b3e8c9","name":"Callula Huy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.magetop.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/321e837578b99a75c9d7f5c884e62e11b3b6df2b5934726e98fd365f580393c7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/321e837578b99a75c9d7f5c884e62e11b3b6df2b5934726e98fd365f580393c7?s=96&d=mm&r=g","caption":"Callula Huy"},"description":"Callula is the Marketing Executive at Magetop. With more than 5 years of copywriting under his belt, Callula is into creating valuable content that is straight to the point. Life student. Workaholic. Foreign languages and traveling aficionado.","sameAs":["http:\/\/magetop.com"],"url":"https:\/\/www.magetop.com\/blog\/author\/callula-huy\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2023\/08\/Using-SQL-Distinct-Query-in-Magento-2-A-Step-by-Step-Guide.png?fit=1400%2C1019&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/paOdw5-2eQ","jetpack-related-posts":[{"id":5722,"url":"https:\/\/www.magetop.com\/blog\/fix-add-to-cart-button-not-working-in-magento-2\/","url_meta":{"origin":8608,"position":0},"title":"How To Fix Add To Cart Button Not Working In Magento 2","author":"Aaron LX","date":"June 18, 2021","format":false,"excerpt":"The add cart button stops working suddenly without knowing the reason. In this post, I will guide you on\u00a0How To Fix Add To Cart Button Not Working In Magento 2.","rel":"","context":"In &quot;Magento 2 Tutorials&quot;","block_context":{"text":"Magento 2 Tutorials","link":"https:\/\/www.magetop.com\/blog\/magento-2-tutorials\/"},"img":{"alt_text":"How To Fix Add To Cart Button Not Working In Magento 2","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/06\/How-To-Fix-Add-To-Cart-Button-Not-Working-In-Magento-2.png?fit=1200%2C711&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/06\/How-To-Fix-Add-To-Cart-Button-Not-Working-In-Magento-2.png?fit=1200%2C711&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/06\/How-To-Fix-Add-To-Cart-Button-Not-Working-In-Magento-2.png?fit=1200%2C711&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/06\/How-To-Fix-Add-To-Cart-Button-Not-Working-In-Magento-2.png?fit=1200%2C711&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2021\/06\/How-To-Fix-Add-To-Cart-Button-Not-Working-In-Magento-2.png?fit=1200%2C711&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":9546,"url":"https:\/\/www.magetop.com\/blog\/how-to-create-a-magento-2-product-page-using-reactjs\/","url_meta":{"origin":8608,"position":1},"title":"How to Create a Magento 2 Product Page Using ReactJS","author":"Adam Roger","date":"November 13, 2024","format":false,"excerpt":"In this post, we will demonstrate how to establish a product page. Since its inception, Magento 2 has been utilizing ReactJS. Interact with the project to configure GraphQL queries.","rel":"","context":"In &quot;Magetop Guest Post&quot;","block_context":{"text":"Magetop Guest Post","link":"https:\/\/www.magetop.com\/blog\/welcome-to-our-guest-post\/"},"img":{"alt_text":"How to Create a Magento 2 Product Page Using ReactJS","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2024\/11\/How-to-Create-a-Magento-2-Product-Page-Using-ReactJS.png?fit=1024%2C576&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2024\/11\/How-to-Create-a-Magento-2-Product-Page-Using-ReactJS.png?fit=1024%2C576&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2024\/11\/How-to-Create-a-Magento-2-Product-Page-Using-ReactJS.png?fit=1024%2C576&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2024\/11\/How-to-Create-a-Magento-2-Product-Page-Using-ReactJS.png?fit=1024%2C576&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":10868,"url":"https:\/\/www.magetop.com\/blog\/how-to-build-a-headless-magento-2-storefront-using-graphql-step-by-step-guide\/","url_meta":{"origin":8608,"position":2},"title":"How To Build A Headless Magento 2 Storefront Using GraphQL (Step-by-Step Guide)","author":"Aaron LX","date":"November 11, 2025","format":false,"excerpt":"Headless commerce is rapidly reshaping the Magento ecosystem. With the growing adoption of GraphQL, developers can now build fast, flexible, and decoupled storefronts that enhance performance and scalability.In this guide, we\u2019ll explore how to build a headless Magento 2 storefront using GraphQL, from enabling the API to integrating it with\u2026","rel":"","context":"In &quot;Magento 2 Knowledge Base&quot;","block_context":{"text":"Magento 2 Knowledge Base","link":"https:\/\/www.magetop.com\/blog\/magento-2-knowledge-base\/"},"img":{"alt_text":"Build A Headless Magento 2 Storefront With GraphQL","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Headless-Magento-2-GraphQL.png?fit=1200%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Headless-Magento-2-GraphQL.png?fit=1200%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Headless-Magento-2-GraphQL.png?fit=1200%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Headless-Magento-2-GraphQL.png?fit=1200%2C667&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Headless-Magento-2-GraphQL.png?fit=1200%2C667&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":10788,"url":"https:\/\/www.magetop.com\/blog\/how-to-use-new-relic-apm-with-magento-2\/","url_meta":{"origin":8608,"position":3},"title":"How To Use New Relic APM With Magento 2","author":"Aaron LX","date":"October 21, 2025","format":false,"excerpt":"Monitoring your Magento 2 store performance is crucial for maintaining speed and reliability.With New Relic APM (Application Performance Monitoring), you can track real-time metrics, detect slow PHP transactions, and analyze server performance easily. In this guide, you\u2019ll learn how to set up New Relic APM with Magento 2 using the\u2026","rel":"","context":"In &quot;Magento 2 Tutorials&quot;","block_context":{"text":"Magento 2 Tutorials","link":"https:\/\/www.magetop.com\/blog\/magento-2-tutorials\/"},"img":{"alt_text":"How To Use New Relic APM With Magento 2","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/10\/How-To-Use-New-Relic-APM-With-Magento-2.png?fit=1200%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/10\/How-To-Use-New-Relic-APM-With-Magento-2.png?fit=1200%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/10\/How-To-Use-New-Relic-APM-With-Magento-2.png?fit=1200%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/10\/How-To-Use-New-Relic-APM-With-Magento-2.png?fit=1200%2C667&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/10\/How-To-Use-New-Relic-APM-With-Magento-2.png?fit=1200%2C667&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":10904,"url":"https:\/\/www.magetop.com\/blog\/magento-2-graphql-security-risks\/","url_meta":{"origin":8608,"position":4},"title":"Common Security Risks When Using GraphQL In Magento 2","author":"Aaron LX","date":"November 19, 2025","format":false,"excerpt":"As GraphQL becomes a core part of modern Magento 2 headless architectures, developers gain unprecedented flexibility in how they query and deliver storefront data. But with this power comes a new layer of security considerations that differ significantly from traditional REST endpoints.Whether you're building a PWA, a custom storefront, or\u2026","rel":"","context":"In &quot;Magento 2 Knowledge Base&quot;","block_context":{"text":"Magento 2 Knowledge Base","link":"https:\/\/www.magetop.com\/blog\/magento-2-knowledge-base\/"},"img":{"alt_text":"Common Security Risks When Using GraphQL In Magento 2","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Common-Security-Risks-When-Using-GraphQL-In-Magento-2.png?fit=1200%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Common-Security-Risks-When-Using-GraphQL-In-Magento-2.png?fit=1200%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Common-Security-Risks-When-Using-GraphQL-In-Magento-2.png?fit=1200%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Common-Security-Risks-When-Using-GraphQL-In-Magento-2.png?fit=1200%2C667&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Common-Security-Risks-When-Using-GraphQL-In-Magento-2.png?fit=1200%2C667&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":10914,"url":"https:\/\/www.magetop.com\/blog\/magento-2-performance-trends\/","url_meta":{"origin":8608,"position":5},"title":"Magento 2 Performance Trends in 2025","author":"Aaron LX","date":"November 23, 2025","format":false,"excerpt":"As ecommerce becomes increasingly competitive, website speed and scalability are no longer optional\u2014they\u2019re fundamental. Magento merchants and developers must keep up with the latest improvements to maintain optimal performance. In this article, we\u2019ll explore the top Magento 2 performance trends in 2025 and how they impact modern storefronts. 1. Shift\u2026","rel":"","context":"In &quot;Magento News&quot;","block_context":{"text":"Magento News","link":"https:\/\/www.magetop.com\/blog\/magento-news\/"},"img":{"alt_text":"Magento 2 Performance Trends in 2025","src":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Magento-2-Performance-Trends-in-2025.png?fit=1200%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Magento-2-Performance-Trends-in-2025.png?fit=1200%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Magento-2-Performance-Trends-in-2025.png?fit=1200%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Magento-2-Performance-Trends-in-2025.png?fit=1200%2C667&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.magetop.com\/blog\/wp-content\/uploads\/2025\/11\/Magento-2-Performance-Trends-in-2025.png?fit=1200%2C667&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/posts\/8608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/users\/108"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/comments?post=8608"}],"version-history":[{"count":4,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/posts\/8608\/revisions"}],"predecessor-version":[{"id":8631,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/posts\/8608\/revisions\/8631"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/media\/8628"}],"wp:attachment":[{"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/media?parent=8608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/categories?post=8608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magetop.com\/blog\/wp-json\/wp\/v2\/tags?post=8608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}