{"id":403,"date":"2016-01-15T16:06:42","date_gmt":"2016-01-15T16:06:42","guid":{"rendered":"http:\/\/sushilkumar.ind.in\/?p=403"},"modified":"2017-09-24T00:15:45","modified_gmt":"2017-09-24T00:15:45","slug":"create-swtch-color-on-product-list-page-in-magento","status":"publish","type":"post","link":"https:\/\/www.sushilkumar.ind.in\/blog\/magento\/create-swtch-color-on-product-list-page-in-magento\/","title":{"rendered":"Create swtch color on product list page in Magento"},"content":{"rendered":"<p><strong>Copy<\/strong> and <strong>past<\/strong> the code . where you want to display color\u00a0 below the name or above the name.<\/p>\n<p>follow the following steps:<\/p>\n<p>images updated in configurable simple product\u00a0 acording to color .<\/p>\n<p>Change Visibility <span class=\"required\">*: catalog search<\/span><\/p>\n<p><strong>\u00a0List.phtml<\/strong><\/p>\n<pre>&lt;? if($_product-&gt;getTypeId() == \"configurable\"):\r\n    $conf = Mage::getModel('catalog\/product_type_configurable')-&gt;setProduct($_product);\r\n    $simple_collection = $conf-&gt;getUsedProductCollection()-&gt;addAttributeToSelect('*')-&gt;addFilterByRequiredOptions();\r\n    foreach($simple_collection as $simple_product){\r\n      \/\/ echo $simple_product-&gt;getSku() . \" - \" . $simple_product-&gt;getName() . \" - \" . Mage::helper('core')-&gt;currency($simple_product-&gt;getPrice()) . \"\r\n\";\r\n    ?&gt;\r\n         <a href=\"&lt;? echo $simple_product-&gt;getUrlKey(); ?&gt;.html\"><img decoding=\"async\" style=\"height: 30px !important; width: 30px !important; border: 1px solid #ccc;\" src=\"&lt;?= $this-&gt;helper('catalog\/image')-&gt;init($simple_product, 'image'); ?&gt;\" \/><\/a>\r\n     \r\n &lt;? } endif;?&gt;<\/pre>\n<p>&lt;? $product = Mage::getModel(&#8216;catalog\/product&#8217;)-&gt;load($_product-&gt;getId()); foreach ($product-&gt;getMediaGalleryImages() as $image) { $image-&gt;getUrl();?&gt; &lt;? } ?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Copy and past the code . where you want to display color\u00a0 below the name or above the name. follow the following steps: images updated in configurable simple product\u00a0 acording to color . Change Visibility *: catalog search \u00a0List.phtml &lt;? if($_product-&gt;getTypeId() == &#8220;configurable&#8221;): $conf = Mage::getModel(&#8216;catalog\/product_type_configurable&#8217;)-&gt;setProduct($_product); $simple_collection = $conf-&gt;getUsedProductCollection()-&gt;addAttributeToSelect(&#8216;*&#8217;)-&gt;addFilterByRequiredOptions(); foreach($simple_collection as $simple_product){ \/\/ echo $simple_product-&gt;getSku() &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[363],"tags":[21,22,26],"class_list":["post-403","post","type-post","status-publish","format-standard","","category-magento","tag-magento","tag-magento-2","tag-magento-2-technology"],"jetpack_publicize_connections":[],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p99pkJ-6v","_links":{"self":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/403"}],"collection":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/comments?post=403"}],"version-history":[{"count":0,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/403\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/media?parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/categories?post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/tags?post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}