{"id":354833,"date":"2022-10-14T05:21:59","date_gmt":"2022-10-14T05:21:59","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=354833"},"modified":"2025-12-17T12:30:37","modified_gmt":"2025-12-17T12:30:37","slug":"create-custom-product-slider-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/","title":{"rendered":"Create Custom Product Slider in Magento 2"},"content":{"rendered":"\n<p>We\u2019ll explore how to create a custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table. <\/p>\n\n\n\n<p>Here we will use slick slider to show content. You can show your custom product collection anywhere on the page. You can provide the custom settings for the slick slider in the slick() as a json object.<\/p>\n\n\n\n<p>Here you can find the full configration that can be set in slick function.<br><a href=\"https:\/\/www.npmjs.com\/package\/slick-slider\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.npmjs.com\/package\/slick-slider<\/a><\/p>\n\n\n\n<p>For better understanding of creating module, You can create module as per the give instruction in following link<br><a href=\"https:\/\/experienceleague.adobe.com\/docs\/commerce-learn\/tutorials\/frontend-development\/create-new-page.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/experienceleague.adobe.com\/docs\/commerce-learn\/tutorials\/frontend-development\/create-new-page.html<\/a><br>Let&#8217;s suppose our vendor name is <strong>Vendor<\/strong> and Module name is <strong>Module<\/strong>.<\/p>\n\n\n\n<p><strong>Note: <\/strong>This blog will work on magento 2.4.3 and later versions.<\/p>\n\n\n\n<p>Let&#8217;s create a controller for accessing the page on storefront. This will load the layout page and its required content.<br>Path:- app\/code\/Vendor\/Module\/Controller\/Index\/MyProdList.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Vendor\\Module\\Controller\\Index;\n\nclass MyProdList extends \\Magento\\Framework\\App\\Action\\Action\n{\n\tprotected $_pageFactory;\n\n\tpublic function __construct(\n\t\t\\Magento\\Framework\\App\\Action\\Context $context,\n\t\t\\Magento\\Framework\\View\\Result\\PageFactory $pageFactory\n        )\n\t{\n\t\t$this-&gt;_pageFactory = $pageFactory;\n\t\treturn parent::__construct($context);\n\t}\n\n\tpublic function execute()\n\t{\n\t\treturn $this-&gt;_pageFactory-&gt;create();\n\t}\n}<\/pre>\n\n\n\n<p>This is our layout file. You can use 1 column, 2 columns etc as per your need. You can also use the following block in your existing page such as catalog category page, catalog product page, customer pages etc.<br>Path:- app\/code\/Vendor\/Module\/view\/frontend\/layout\/vendormod_index_myprodlist.xml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; layout=&quot;1column&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;referenceContainer name=&quot;content&quot;&gt;\n        &lt;block class=&quot;Vendor\\Module\\Block\\ProductList&quot; name=&quot;vendormod_index_myprodlist&quot; template=&quot;Vendor_Module::index.phtml&quot; \/&gt;\n    &lt;\/referenceContainer&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Here is our block which is responsible for getting product collection and required params for adding product to cart, getting form key, getting price renderer etc. This file extends the block \\Magento\\Catalog\\Block\\Product\\AbstractProduct. <br>Path:- app\/code\/Vendor\/Module\/Block\/ProductList.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Vendor\\Module\\Block;\nuse Magento\\Catalog\\Pricing\\Price\\FinalPrice;\nuse Magento\\Framework\\Pricing\\Render;\nuse Magento\\Framework\\App\\ActionInterface;\n\nclass ProductList extends \\Magento\\Catalog\\Block\\Product\\AbstractProduct\n{\n    \n    \/**\n     * @var \\Magento\\Framework\\Url\\Helper\\Data\n     *\/\n    protected $urlHelper;\n    \n    \/**\n     * @var \\Magento\\Catalog\\Model\\ProductFactory\n     *\/\n    protected $productFactory;\n\n    \/**\n     * @param Context $context\n     * @param \\Magento\\Framework\\Url\\Helper\\Data $urlHelper\n     * @param \\Magento\\Catalog\\Model\\ProductFactory $productloader\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Catalog\\Block\\Product\\Context $context,\n        \\Magento\\Framework\\Url\\Helper\\Data $urlHelper,\n        \\Magento\\Catalog\\Model\\ProductFactory $productloader,\n        \\Magento\\Framework\\Data\\Form\\FormKey $formKey,\n        array $data = &#091;]\n    ) {\n        $this-&gt;urlHelper = $urlHelper;\n        $this-&gt;productFactory = $productloader;\n        $this-&gt;formKey = $formKey;\n        parent::__construct($context, $data);\n    }\n    \/**\n     * Get form key\n     *\n     * @return string\n     *\/\n    public function getFormKey()\n    {\n        return $this-&gt;formKey-&gt;getFormKey();\n    }\n    \/**\n     * Load Products collection\n     *\n     * @return Product array\n     *\/\n    public function getLoadProducts()\n    {\n        $products = $this-&gt;productFactory-&gt;create()-&gt;getCollection()\n                    -&gt;addAttributeToSelect(&#091;&quot;name&quot;, &quot;price&quot;, &quot;image&quot;])\n                    \/\/Custom filter on attributes\n                    \/\/category filter\n                    \/\/join with other table\n                    \/\/-&gt;addAttributeToFilter(IndustryType::PRODUCT_ATTRIBUTE_CODE, &#091;&quot;eq&quot; =&gt; $attributeValue])\n                    -&gt;addAttributeToFilter(&quot;visibility&quot;, &#091;&#039;neq&#039; =&gt; 1]);\n        return $products;\n    }\n    \/**\n     * Load Product\n     *\n     * @return Product array\n     *\/\n    public function getLoadProduct($id)\n    {\n        return $this-&gt;productFactory-&gt;create()-&gt;load($id);\n    }\n    \n    \/**\n     * Get post parameters\n     *\n     * @param \\Magento\\Catalog\\Model\\Product $product\n     * @return array\n     *\/\n    public function getAddToCartPostParams(\\Magento\\Catalog\\Model\\Product $product)\n    {\n        $url = $this-&gt;getAddToCartUrl($product, &#091;&#039;_escape&#039; =&gt; false]);\n        return &#091;\n            &#039;action&#039; =&gt; $url,\n            &#039;data&#039; =&gt; &#091;\n                &#039;product&#039; =&gt; (int) $product-&gt;getEntityId(),\n                ActionInterface::PARAM_NAME_URL_ENCODED =&gt;\n                    $this-&gt;urlHelper-&gt;getEncodedUrl($url),\n            ]\n        ];\n    }\n    \/**\n     * Get product price.\n     *\n     * @param \\Magento\\Catalog\\Model\\Product $product\n     * @return string\n     *\/\n    public function getProductPrice(\\Magento\\Catalog\\Model\\Product $product)\n    {\n        $priceRender = $this-&gt;getPriceRender($product);\n        $price = &#039;&#039;;\n        if ($priceRender) {\n            $price = $priceRender-&gt;render(\n                FinalPrice::PRICE_CODE,\n                $product,\n                &#091;\n                    &#039;include_container&#039; =&gt; true,\n                    &#039;display_minimal_price&#039; =&gt; true,\n                    &#039;zone&#039; =&gt; Render::ZONE_ITEM_LIST,\n                    &#039;list_category_page&#039; =&gt; true\n                ]\n            );\n        }\n        return $price;\n    }\n\n    \/**\n     * Get price render\n     *\n     * @param \\Magento\\Catalog\\Model\\Product $product\n     * @return Render\n     *\/\n    protected function getPriceRender($product)\n    {\n        return $this-&gt;getLayout()-&gt;createBlock(\\Magento\\Framework\\Pricing\\Render::class, &quot;product.price.render.default&quot;.$product-&gt;getSku())\n            -&gt;setData(&#039;is_product_list&#039;, true);\n    }\n    \n}<\/pre>\n\n\n\n<p>This is our phtml file which represent the slider on page.  You can put the following code before, after or in the middle of the content.<br>Path:- app\/code\/Vendor\/Module\/view\/frontend\/templates\/index.phtml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nuse Magento\\Framework\\App\\Action\\Action;\n$_productCollection = $block-&gt;getLoadProducts();\nif ($_productCollection-&gt;getSize() &lt;= 0) {\n    return;   \n}\n?&gt;\n&lt;h2&gt;&lt;center&gt;Product list carousel&lt;\/center&gt;&lt;\/h2&gt;\n&lt;div class=&quot;container-&quot;&gt;\n&lt;?php $_helper = $this-&gt;helper(&#039;Magento\\Catalog\\Helper\\Output&#039;); ?&gt;\n&lt;?php \n$viewMode = &#039;grid&#039;;\n$image = &#039;category_page_grid&#039;;\n$showDescription = false;\n$templateType = \\Magento\\Catalog\\Block\\Product\\ReviewRendererInterface::SHORT_VIEW;\n$pos = $block-&gt;getPositioned();\n$position = &#039;&#039;;\n$formKey = $block-&gt;getFormKey();\n?&gt;\n&lt;style&gt;\n    .products-grid .product-item-inner{\n        margin:unset;\n    }\n    &lt;\/style&gt;\n&lt;?php $count = 1; ?&gt;\n\t&lt;div class=&quot;ind-container&quot;&gt;\t\n        &lt;div class=&quot; products wrapper grid products-grid &lt;?php \/* @escapeNotVerified *\/ echo $viewMode; ?&gt; products-&lt;?php \/* @escapeNotVerified *\/ echo $viewMode; ?&gt;&quot;&gt;\n            &lt;?php $iterator = 1; ?&gt;\n            &lt;div class=&quot;products grid items product-items slick-carousel&quot; &gt;\n                &lt;?php $prdCount = 0; ?&gt;\n                &lt;?php foreach($_productCollection as $_product): \n                    \n                    ?&gt;\n                    &lt;?php $_product = $block-&gt;getLoadProduct($_product-&gt;getEntityId()); ?&gt;\n                    &lt;div class=&quot;item product product-item&quot;&gt;\n                        &lt;div class=&quot;product-item-info item&quot; data-container=&quot;product-grid&quot;&gt;\n                            &lt;?php\n                            $productImage = $block-&gt;getImage($_product, $image);\n                            if ($pos != null) {\n                                $position = &#039; style=&quot;left:&#039; . $productImage-&gt;getWidth() . &#039;px;&#039;\n                                    . &#039;top:&#039; . $productImage-&gt;getHeight() . &#039;px;&quot;&#039;;\n                            }\n                            ?&gt;\n                            &lt;?php \/\/ Product Image ?&gt;\n                            &lt;a href=&quot;&lt;?php \/* @escapeNotVerified *\/ echo $_product-&gt;getProductUrl() ?&gt;&quot; class=&quot;product photo product-item-photo&quot; tabindex=&quot;-1&quot;&gt;\n                                &lt;?php \/* @escapeNotVerified *\/ echo $productImage-&gt;toHtml(); ?&gt;\n                                &lt;div class=&quot;product-discount&quot;&gt;\n                                    &lt;?php $originalPrice = $_product-&gt;getPrice();\n                                        $finalPrice = $_product-&gt;getFinalPrice();\n                                        $discount = 0;\n                                        if($originalPrice &gt; $finalPrice){\n                                            $discount = number_format(($originalPrice - $finalPrice) * 100 \/ $originalPrice,0);\n                                    ?&gt;\n                                    &lt;div class=&quot;price_section&quot;&gt;\n                                        &lt;span class=&quot;&quot;&gt;&lt;?= $discount.&#039;% Off&#039;; ?&gt;&lt;\/span&gt;\n                                    &lt;\/div&gt;                            \n                                    &lt;?php } ?&gt;\n                                    &lt;a href=&quot;#&quot; \n                                        class=&quot;action towishlist&quot;\n                                        title=&quot;&lt;?php echo $block-&gt;escapeHtml(__(&#039;Add to Wishlist&#039;)); ?&gt;&quot;\n                                        aria-label=&quot;&lt;?php echo $block-&gt;escapeHtml(__(&#039;Add to Wishlist&#039;)); ?&gt;&quot;\n                                        data-post=&#039;&lt;?php \/* @escapeNotVerified *\/ echo $block-&gt;getAddToWishlistParams($_product); ?&gt;&#039;\n                                        data-action=&quot;add-to-wishlist&quot;\n                                        role=&quot;button&quot;&gt;\n                                        &lt;span&gt;&lt;?php \/* @escapeNotVerified *\/ echo __(&#039;Add to Wishlist&#039;) ?&gt;&lt;\/span&gt;\n\t\t\t\t\t\t\t\t\t&lt;\/a&gt;\n                                &lt;\/div&gt;\n                            &lt;\/a&gt;\n                            &lt;div class=&quot;product details product-item-details&quot;&gt;\n                                &lt;?php $_productNameStripped = $block-&gt;stripTags($_product-&gt;getName(), null, true); ?&gt;\n                                &lt;strong class=&quot;product name product-item-name&quot;&gt;\n                                    &lt;a class=&quot;product-item-link&quot;\n                                        href=&quot;&lt;?php \/* @escapeNotVerified *\/ echo $_product-&gt;getProductUrl() ?&gt;&quot;&gt;\n                                        &lt;?php \/* @escapeNotVerified *\/ echo $_helper-&gt;productAttribute($_product, $_product-&gt;getName(), &#039;name&#039;); ?&gt;\n                                    &lt;\/a&gt;\n                                &lt;\/strong&gt;\n                                &lt;?php \/* @escapeNotVerified *\/ echo $block-&gt;getProductPrice($_product);?&gt;\n                                &lt;?php \/* @escapeNotVerified *\/ echo $block-&gt;getReviewsSummaryHtml($_product, $templateType); ?&gt;\n                                \n                                &lt;div class=&quot;product-item-inner&quot;&gt;\n                                    &lt;div class=&quot;product actions product-item-actions&quot;&lt;?php \/* @escapeNotVerified *\/ echo strpos($pos, $viewMode . &#039;-actions&#039;) ? $position : &#039;&#039;; ?&gt;&gt;\n                                            &lt;div class=&quot;actions-primary&quot;&lt;?php \/* @escapeNotVerified *\/ echo strpos($pos, $viewMode . &#039;-primary&#039;) ? $position : &#039;&#039;; ?&gt;&gt;\n                                                &lt;?php if ($_product-&gt;isSaleable()): ?&gt;\n                                                    &lt;?php $postParams = $block-&gt;getAddToCartPostParams($_product); ?&gt;\n                                                    &lt;form data-role=&quot;tocart-form&quot; \n                                                    data-product-sku=&quot;&lt;?= $escaper-&gt;escapeHtml($_product-&gt;getSku()) ?&gt;&quot;\n                                                    action=&quot;&lt;?= $escaper-&gt;escapeUrl($postParams&#091;&#039;action&#039;]) ?&gt;&quot;\n                                                    method=&quot;post&quot;\n                                                    &gt;\n                                                    &lt;input type=&quot;hidden&quot;\n                                                    name=&quot;product&quot;\n                                                    value=&quot;&lt;?= \/* @noEscape *\/ $postParams&#091;&#039;data&#039;]&#091;&#039;product&#039;] ?&gt;&quot;&gt;\n                                                    &lt;input type=&quot;hidden&quot;\n                                                    name=&quot;&lt;?= \/* @noEscape *\/ Action::PARAM_NAME_URL_ENCODED ?&gt;&quot;\n                                                    value=&quot;&lt;?=\n                                                    \/* @noEscape *\/ $postParams&#091;&#039;data&#039;]&#091;Action::PARAM_NAME_URL_ENCODED]\n                                                        ?&gt;&quot;&gt;\n                                                        &lt;input type=&quot;hidden&quot; name=&quot;form_key&quot; value=&quot;&lt;?= \/* @noEscape *\/ $formKey ?&gt;&quot;&gt;\n                                                        \n                                                        &lt;button type=&quot;submit&quot;\n                                                                title=&quot;&lt;?php echo $block-&gt;escapeHtml(__(&#039;Add to Cart&#039;)); ?&gt;&quot;\n                                                                class=&quot;action tocart primary&quot;&gt;\n                                                            &lt;span&gt;&lt;?php \/* @escapeNotVerified *\/ echo __(&#039;Add to Cart&#039;) ?&gt;&lt;\/span&gt;\n                                                        &lt;\/button&gt;\n                                                    &lt;\/form&gt;\n                                                &lt;?php else: ?&gt;\n                                                    &lt;?php if ($_product-&gt;getIsSalable()): ?&gt;\n                                                        &lt;div class=&quot;stock available&quot;&gt;&lt;span&gt;&lt;?php \/* @escapeNotVerified *\/ echo __(&#039;In stock&#039;) ?&gt;&lt;\/span&gt;&lt;\/div&gt;\n                                                    &lt;?php else: ?&gt;\n                                                        &lt;div class=&quot;stock unavailable&quot;&gt;&lt;span&gt;&lt;?php \/* @escapeNotVerified *\/ echo __(&#039;Out of stock&#039;) ?&gt;&lt;\/span&gt;&lt;\/div&gt;\n                                                    &lt;?php endif; ?&gt;\n                                                &lt;?php endif; ?&gt;\n                                            &lt;\/div&gt;\n                                            &lt;!-- &lt;div data-role=&quot;add-to-links&quot; class=&quot;actions-secondary&quot;&lt;?php echo strpos($pos, $viewMode . &#039;-secondary&#039;) ? $position : &#039;&#039;; ?&gt;&gt;\n                                                    \n                                                    &lt;?php $compareHelper = $this-&gt;helper(&#039;Magento\\Catalog\\Helper\\Product\\Compare&#039;);\n                                                    ?&gt;\n                                                    &lt;a href=&quot;#&quot; \n                                                        class=&quot;action tocompare&quot;\n                                                        title=&quot;&lt;?php echo $block-&gt;escapeHtml(__(&#039;Add to Compare&#039;)); ?&gt;&quot;\n                                                        aria-label=&quot;&lt;?php echo $block-&gt;escapeHtml(__(&#039;Add to Compare&#039;)); ?&gt;&quot;\n                                                        data-post=&#039;&lt;?php \/* @escapeNotVerified *\/ echo $compareHelper-&gt;getPostDataParams($_product); ?&gt;&#039;\n                                                        role=&quot;button&quot;&gt;\n                                                        &lt;span&gt;&lt;?php \/* @escapeNotVerified *\/ echo __(&#039;Add to Compare&#039;) ?&gt;&lt;\/span&gt;\n                                                    &lt;\/a&gt;\n                                            &lt;\/div&gt; --&gt;\n                                    &lt;\/div&gt;\n                                &lt;\/div&gt;\n                            &lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;script type=&quot;text\/x-magento-init&quot;&gt;\n                        {\n                            &quot;&#091;data-role=tocart-form], .form.map.checkout&quot;: {\n                                &quot;catalogAddToCart&quot;: {\n                                    &quot;product_sku&quot;: &quot;&lt;?= \/* @noEscape *\/ $_product-&gt;getSku() ?&gt;&quot;\n                                }\n                            }\n                        }\n                        &lt;\/script&gt;\n                    &lt;\/div&gt;\n                &lt;?php endforeach; ?&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n\t&lt;\/div&gt;\n\t&lt;?php $count++; ?&gt; \n&lt;script&gt;\nrequire(&#091;&#039;jquery&#039;, &#039;jquery\/ui&#039;, &#039;slick&#039;], function($) {\n    $(document).ready(function() {\n        $(&quot;.slick-carousel&quot;).slick({\n            dots: true,\n            infinite: false,\n            slidesToShow: 4,\n            slidesToScroll: 1\n        });\n    });\n});\n&lt;\/script&gt;<\/pre>\n\n\n\n<p>Output:- After creating all above files, Here is how the output would be shown.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"576\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png\" alt=\"Screenshot-from-2022-10-13-20-54-13\" class=\"wp-image-354837\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-300x144.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-250x120.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-768x369.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13.png 1221w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Previous Blog <a href=\"https:\/\/webkul.com\/blog\/how-to-pass-data-using-js-widget-in-magento-2\/\">https:\/\/webkul.com\/blog\/how-to-pass-data-using-js-widget-in-magento-2\/<\/a><br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019ll explore how to create a custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table. Here we will use slick slider to show content. You can show your custom product collection anywhere on <a href=\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":440,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2383,1],"tags":[],"class_list":["post-354833","post","type-post","status-publish","format-standard","hentry","category-blog","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create Custom Product Slider in Magento 2<\/title>\n<meta name=\"description\" content=\"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.\" \/>\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\/create-custom-product-slider-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Custom Product Slider in Magento 2\" \/>\n<meta property=\"og:description\" content=\"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\" \/>\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-10-14T05:21:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-17T12:30:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png\" \/>\n<meta name=\"author\" content=\"Amir Khan\" \/>\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=\"Amir Khan\" \/>\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\/create-custom-product-slider-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\"},\"author\":{\"name\":\"Amir Khan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a\"},\"headline\":\"Create Custom Product Slider in Magento 2\",\"datePublished\":\"2022-10-14T05:21:59+00:00\",\"dateModified\":\"2025-12-17T12:30:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\"},\"wordCount\":334,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png\",\"articleSection\":[\"blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\",\"name\":\"Create Custom Product Slider in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png\",\"datePublished\":\"2022-10-14T05:21:59+00:00\",\"dateModified\":\"2025-12-17T12:30:37+00:00\",\"description\":\"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13.png\",\"width\":1221,\"height\":586,\"caption\":\"Screenshot-from-2022-10-13-20-54-13\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create Custom Product Slider in Magento 2\"}]},{\"@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\/f2493d3639b5e8c05ae4e9af5f71063a\",\"name\":\"Amir Khan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?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\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Amir Khan\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/amir-khan754\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Custom Product Slider in Magento 2","description":"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.","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\/create-custom-product-slider-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Create Custom Product Slider in Magento 2","og_description":"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.","og_url":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-10-14T05:21:59+00:00","article_modified_time":"2025-12-17T12:30:37+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png","type":"","width":"","height":""}],"author":"Amir Khan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Amir Khan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/"},"author":{"name":"Amir Khan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a"},"headline":"Create Custom Product Slider in Magento 2","datePublished":"2022-10-14T05:21:59+00:00","dateModified":"2025-12-17T12:30:37+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/"},"wordCount":334,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png","articleSection":["blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/","name":"Create Custom Product Slider in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13-1200x576.png","datePublished":"2022-10-14T05:21:59+00:00","dateModified":"2025-12-17T12:30:37+00:00","description":"Today we will learn how to create custom product slider in Magento 2. On the basis of your need, you can add your own condition such as product attribute filter, category filter, or join with any other table.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-13-20-54-13.png","width":1221,"height":586,"caption":"Screenshot-from-2022-10-13-20-54-13"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/create-custom-product-slider-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create Custom Product Slider in Magento 2"}]},{"@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\/f2493d3639b5e8c05ae4e9af5f71063a","name":"Amir Khan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?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\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Amir Khan"},"url":"https:\/\/webkul.com\/blog\/author\/amir-khan754\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/354833","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\/440"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=354833"}],"version-history":[{"count":18,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/354833\/revisions"}],"predecessor-version":[{"id":517802,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/354833\/revisions\/517802"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=354833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=354833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=354833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}