{"id":282477,"date":"2021-02-09T08:15:45","date_gmt":"2021-02-09T08:15:45","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=282477"},"modified":"2024-08-01T09:34:24","modified_gmt":"2024-08-01T09:34:24","slug":"magento-2-filter-and-sorting","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/","title":{"rendered":"Magento 2 : Filter and Sorting"},"content":{"rendered":"\n<p>We have displayed the blog list but it will show all the blogs. Even if we create a new customer s\/he will be able to see the blogs from the previous customer. So to fix this issue we need to filter our Data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Filter<\/h2>\n\n\n\n<p>If you think in terms of SQL query then you can use WHERE user_id=$customerId but in <a href=\"https:\/\/business.adobe.com\/in\/products\/magento\/magento-commerce.html\">Magento<\/a> we do not write raw SQL queries.<\/p>\n\n\n\n<p>To apply conditions on the collection we have to use the addFieldToFilter method. Let&#8217;s check out the code for a better understanding, we have to edit the <em>Block\/BlogList.php<\/em> because we are sending the data from here only,<\/p>\n\n\n\n<p>Updated code for <em>Block\/BlogList.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Block;\n\nuse Magento\\Customer\\Model\\SessionFactory;\n\nclass BlogList extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory\n     *\/\n    protected $blogCollection;\n\n    \/**\n     * @var Magento\\Customer\\Model\\SessionFactory\n     *\/\n    protected $customerSession;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection,\n        SessionFactory $customerSession,\n        array $data = &#091;]\n    ) {\n        $this-&gt;blogCollection = $blogCollection;\n        $this-&gt;customerSession = $customerSession;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Get Blog List\n     *\n     * @return \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    public function getBlogs()\n    {\n        $customerId = $this-&gt;customerSession-&gt;create()-&gt;getCustomer()-&gt;getId();\n        $collection = $this-&gt;blogCollection-&gt;create();\n        $collection-&gt;addFieldToFilter(&#039;user_id&#039;, &#091;&#039;eq&#039;=&gt;$customerId]);\n        return $collection;\n    }\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"603\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png\" alt=\"Selection_110\" class=\"wp-image-390817\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-300x151.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-250x126.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-768x386.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110.png 1530w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Here we have used the customer session to get the customer id. Now please take note of <strong>->addFieldToFilter(&#8216;user_id&#8217;,  [&#8216;eq&#8217;=>$customerId]);<\/strong> in the first param, we have passed the column name. <\/p>\n\n\n\n<p>And in the second param, we have passed an associative array, whose key represents the operators. <strong>eq <\/strong>means equal operator. Some other important operators are,<\/p>\n\n\n\n<p>[&#8220;eq&#8221; => $equalValue]<br>[&#8220;neq&#8221; => $notEqualValue]<br>[&#8220;like&#8221; => $likeValue]<\/p>\n\n\n\n<p>[&#8220;in&#8221; => [$inValues]]<br>[&#8220;nin&#8221; => [$notInValues]]<br>[&#8220;notnull&#8221; => $valueIsNotNull]<\/p>\n\n\n\n<p>[&#8220;null&#8221; => $valueIsNul[&#8220;gt&#8221; => $greaterValue]<br>[&#8220;lt&#8221; => $lessValue]<br>[&#8220;gteq&#8221; => $greaterOrEqualValue]<br>[&#8220;lteq&#8221; => $lessOrEqualValue]<br>[&#8220;from&#8221; => $fromValue, &#8220;to&#8221; => $toValue]<\/p>\n\n\n\n<p>If we do not provide any operator then it just uses the equal operator, which means here we can use <strong>-&gt;addFieldToFilter(&#8216;user_id&#8217;, $customerId)<\/strong> also.<\/p>\n\n\n\n<p>To combine multiple conditions with the AND operator we have to use multiple <strong>addFieldToFilter<\/strong> methods. So for example, <strong>WHERE (`user_id` = &#8216;1&#8217;) AND (`status` != 0)<\/strong> can be achieved with following code,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$collection-&gt;addFieldToFilter(&#039;user_id&#039;, $customerId)\n           -&gt;addFieldToFilter(&#039;status&#039;, &#091;&#039;neq&#039;=&gt;0]);<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sorting<\/h2>\n\n\n\n<p>It will be better from a usability standpoint if we show the latest blogs at the top. In SQL we use ORDER BY to sort. Let&#8217;s see how can we sort in Magento, we have to edit the <em>Block\/BlogList.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Block\/BlogList.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Block;\n\nuse Magento\\Customer\\Model\\SessionFactory;\n\nclass BlogList extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory\n     *\/\n    protected $blogCollection;\n\n    \/**\n     * @var Magento\\Customer\\Model\\SessionFactory\n     *\/\n    protected $customerSession;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection,\n        SessionFactory $customerSession,\n        array $data = &#091;]\n    ) {\n        $this-&gt;blogCollection = $blogCollection;\n        $this-&gt;customerSession = $customerSession;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Get Blog List\n     *\n     * @return \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    public function getBlogs()\n    {\n        $customerId = $this-&gt;customerSession-&gt;create()-&gt;getCustomer()-&gt;getId();\n        $collection = $this-&gt;blogCollection-&gt;create();\n        $collection-&gt;addFieldToFilter(&#039;user_id&#039;, &#091;&#039;eq&#039;=&gt;$customerId])-&gt;setOrder(&#039;updated_at&#039;, &#039;DESC&#039;)   ;\n        return $collection;\n    }\n}<\/pre>\n\n\n\n<p>To sort we use the <strong>setOrder<\/strong> method where in the first param we have to pass the column name and in the second we have to mention whether we want to sort in ascending or descending order. Here we are updating based on the updated_at column so the latest updated blogs will come at the top.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"604\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111-1200x604.png\" alt=\"Selection_111\" class=\"wp-image-390820\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111-1200x604.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111-300x151.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111-250x126.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111-768x386.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_111.png 1525w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Here you can see that the latest blog is coming at the top. Also, we are seeing only those blogs which have user_id the same as the current customer id.<\/p>\n\n\n\n<p>PS. We can view the actual SELECT query for the collection by printing the <strong>$collection-&gt;getSelect(); <\/strong><\/p>\n\n\n\n<p>We have not created any files so the folder structure will remain the same.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"519\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112-1200x519.png\" alt=\"Selection_112\" class=\"wp-image-390822\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112-1200x519.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112-300x130.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112-250x108.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112-768x332.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_112.png 1503w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Folder Structure<\/figcaption><\/figure>\n\n\n\n<p>Next Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/magento-development-09-editing-and-updating\/\">Magento 2 Development 12: Editing and Updating<\/a><\/p>\n\n\n\n<p>Previous Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/magento-development-07-collection-and-block\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Development 10: Collection and Block<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have displayed the blog list but it will show all the blogs. Even if we create a new customer s\/he will be able to see the blogs from the previous customer. So to fix this issue we need to filter our Data. Filter If you think in terms of SQL query then you can <a href=\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[2056,2460],"class_list":["post-282477","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-magento","tag-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento 2 : Filter and Sorting - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2 : Filter and Sorting - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"We have displayed the blog list but it will show all the blogs. Even if we create a new customer s\/he will be able to see the blogs from the previous customer. So to fix this issue we need to filter our Data. Filter If you think in terms of SQL query then you can [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\" \/>\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=\"2021-02-09T08:15:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-01T09:34:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\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=\"Sanjay Chouhan\" \/>\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:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"Magento 2 : Filter and Sorting\",\"datePublished\":\"2021-02-09T08:15:45+00:00\",\"dateModified\":\"2024-08-01T09:34:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\"},\"wordCount\":451,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png\",\"keywords\":[\"magento\",\"Magento 2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\",\"name\":\"Magento 2 : Filter and Sorting - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png\",\"datePublished\":\"2021-02-09T08:15:45+00:00\",\"dateModified\":\"2024-08-01T09:34:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110.png\",\"width\":1530,\"height\":769,\"caption\":\"Selection_110\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2 : Filter and Sorting\"}]},{\"@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\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?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\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2 : Filter and Sorting - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2 : Filter and Sorting - Webkul Blog","og_description":"We have displayed the blog list but it will show all the blogs. Even if we create a new customer s\/he will be able to see the blogs from the previous customer. So to fix this issue we need to filter our Data. Filter If you think in terms of SQL query then you can [...]","og_url":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-02-09T08:15:45+00:00","article_modified_time":"2024-08-01T09:34:24+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"Magento 2 : Filter and Sorting","datePublished":"2021-02-09T08:15:45+00:00","dateModified":"2024-08-01T09:34:24+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/"},"wordCount":451,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png","keywords":["magento","Magento 2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/","url":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/","name":"Magento 2 : Filter and Sorting - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110-1200x603.png","datePublished":"2021-02-09T08:15:45+00:00","dateModified":"2024-08-01T09:34:24+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/07\/Selection_110.png","width":1530,"height":769,"caption":"Selection_110"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-2-filter-and-sorting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2 : Filter and Sorting"}]},{"@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\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?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\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/282477","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\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=282477"}],"version-history":[{"count":12,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/282477\/revisions"}],"predecessor-version":[{"id":455765,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/282477\/revisions\/455765"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=282477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=282477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=282477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}