Magento 2 - Override Swatches renderer.phtmlMagento 2 - Override base view fileMagento 2 - Override base view fileOverride Magento 2 Adminhtml Template FileHow to override a phtml file from a custom module in magento 2?Unable to override Braintree PayPal button viewNot able to override phtml fileMagento2: How to override paypal-express.html & authorizenet-directpost.html?Override template phtml file in magento 2?Extend tier_price.phtml in child theme of a custom theme Magento 2Magento 2 : How to override a custom module which install via composer?how to override Custom theme phtml file by custom module

SQL Server Management Studio SSMS 18.0 General Availability release (GA) install fails

Short story with physics professor who "brings back the dead" (Asimov or Bradbury?)

Why is B♯ higher than C♭ in 31-ET?

Answer "Justification for travel support" in conference registration form

Is this homebrew life-stealing melee cantrip unbalanced?

Pressure inside an infinite ocean?

Why is `abs()` implemented differently?

Airbnb - host wants to reduce rooms, can we get refund?

Does this article imply that Turing-Computability is not the same as "effectively computable"?

What is a "listed natural gas appliance"?

Junior developer struggles: how to communicate with management?

How to give very negative feedback gracefully?

Is Cola "probably the best-known" Latin word in the world? If not, which might it be?

Do I have to make someone coauthor if he/she solves a problem in StackExchange, asked by myself, which is later used in my paper?

Point of the the Dothraki's attack in GoT S8E3?

Can fracking help reduce CO2?

Are we obligated to aspire to be Talmidei Chachamim?

Should one double the thirds or the fifth in chords?

Reconstruct a matrix from its traces

If 1. e4 c6 is considered as a sound defense for black, why is 1. c3 so rare?

Pawn Promotion Double Checks

In a Latex Table, how can I automatically resize cell heights to account for superscripts?

Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?

Unknowingly ran an infinite loop in terminal



Magento 2 - Override Swatches renderer.phtml


Magento 2 - Override base view fileMagento 2 - Override base view fileOverride Magento 2 Adminhtml Template FileHow to override a phtml file from a custom module in magento 2?Unable to override Braintree PayPal button viewNot able to override phtml fileMagento2: How to override paypal-express.html & authorizenet-directpost.html?Override template phtml file in magento 2?Extend tier_price.phtml in child theme of a custom theme Magento 2Magento 2 : How to override a custom module which install via composer?how to override Custom theme phtml file by custom module






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I would like to override file :



app/code/Magento/Swatches/view/frontend/templates/product/layered/renderer.phtml


In my own theme :



app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/layered/renderer.phtml


It does not work. Is it a path problem?
Do I copy it in the right place?



I followed this instruction but I think something is wrong for file I want to override :
Magento 2 - Override base view file



Thank you in advance for your support.



I'm on Magento 2.3.1



Best regards,
Florian










share|improve this question







New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

    – Pawan
    2 days ago











  • Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

    – Jimmy Labuche
    2 days ago


















1















I would like to override file :



app/code/Magento/Swatches/view/frontend/templates/product/layered/renderer.phtml


In my own theme :



app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/layered/renderer.phtml


It does not work. Is it a path problem?
Do I copy it in the right place?



I followed this instruction but I think something is wrong for file I want to override :
Magento 2 - Override base view file



Thank you in advance for your support.



I'm on Magento 2.3.1



Best regards,
Florian










share|improve this question







New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

    – Pawan
    2 days ago











  • Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

    – Jimmy Labuche
    2 days ago














1












1








1


1






I would like to override file :



app/code/Magento/Swatches/view/frontend/templates/product/layered/renderer.phtml


In my own theme :



app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/layered/renderer.phtml


It does not work. Is it a path problem?
Do I copy it in the right place?



I followed this instruction but I think something is wrong for file I want to override :
Magento 2 - Override base view file



Thank you in advance for your support.



I'm on Magento 2.3.1



Best regards,
Florian










share|improve this question







New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I would like to override file :



app/code/Magento/Swatches/view/frontend/templates/product/layered/renderer.phtml


In my own theme :



app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/layered/renderer.phtml


It does not work. Is it a path problem?
Do I copy it in the right place?



I followed this instruction but I think something is wrong for file I want to override :
Magento 2 - Override base view file



Thank you in advance for your support.



I'm on Magento 2.3.1



Best regards,
Florian







magento2 template frontend phtml






share|improve this question







New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 27 at 18:27









Jimmy LabucheJimmy Labuche

64




64




New contributor




Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

    – Pawan
    2 days ago











  • Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

    – Jimmy Labuche
    2 days ago


















  • path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

    – Pawan
    2 days ago











  • Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

    – Jimmy Labuche
    2 days ago

















path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

– Pawan
2 days ago





path seems correct to me. Please check theme is applied in which you overriding. If you are in production mode, you need to deploy content as well!

– Pawan
2 days ago













Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

– Jimmy Labuche
2 days ago






Hi @Pawan, Thanks for your comment. The theme is good, and I already deployed content. But problem is still here :( Thanks !

– Jimmy Labuche
2 days ago











2 Answers
2






active

oldest

votes


















0














If you want to customize in product listing page. Kindly override in the following path




app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/listing/renderer.phtml




If you want to customize in product detail page. Kindly override in the following path




app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/view/renderer.phtml







share|improve this answer






























    0














    Thanks @ARUNPRABAKARAN-M,



    I think this is the good solution cause now I've an error on product page.



    Please see below :



    1 exception(s):
    Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16

    Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16
    <pre>#1 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
    #2 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
    #3 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:609]
    #4 MagentoSwatchesBlockProductRendererConfigurableInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
    #5 MagentoFrameworkViewElementTemplate->_toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:461]
    #6 MagentoSwatchesBlockProductRendererConfigurable->getHtmlOutput() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:439]
    #7 MagentoSwatchesBlockProductRendererConfigurable->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
    #8 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:429]
    #9 MagentoSwatchesBlockProductRendererConfigurable->toHtml() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:89]
    #10 MagentoSwatchesBlockProductRendererConfigurableInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
    #11 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
    #12 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #13 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #14 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #15 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:512]
    #16 MagentoFrameworkViewElementAbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:778]
    #17 MagentoCatalogBlockProductViewInterceptor->getChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/options/wrapper.phtml:15]
    #18 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
    #19 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
    #20 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
    #21 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
    #22 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
    #23 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
    #24 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
    #25 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
    #26 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #27 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #28 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #29 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:543]
    #30 MagentoFrameworkViewElementAbstractBlock->getChildChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:791]
    #31 MagentoCatalogBlockProductViewInterceptor->getChildChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml:32]
    #32 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
    #33 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
    #34 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
    #35 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
    #36 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
    #37 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
    #38 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
    #39 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
    #40 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #41 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #42 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #43 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #44 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #45 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #46 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #47 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #48 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #49 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #50 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #51 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #52 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #53 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #54 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #55 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #56 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #57 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #58 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #59 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #60 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #61 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #62 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #63 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #64 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #65 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #66 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #67 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #68 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #69 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #70 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #71 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #72 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #73 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
    #74 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
    #75 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
    #76 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
    #77 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
    #78 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:954]
    #79 MagentoFrameworkViewLayout->getOutput() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
    #80 MagentoFrameworkViewLayoutInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
    #81 MagentoFrameworkViewLayoutInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
    #82 MagentoFrameworkViewLayoutInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
    #83 MagentoFrameworkViewLayoutInterceptor->getOutput() called at [lib/internal/Magento/Framework/View/Result/Page.php:258]
    #84 MagentoFrameworkViewResultPage->render() called at [lib/internal/Magento/Framework/View/Result/Layout.php:171]
    #85 MagentoFrameworkViewResultLayout->renderResult() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
    #86 MagentoFrameworkViewResultPageInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
    #87 MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
    #88 MagentoFrameworkViewResultPageInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
    #89 MagentoFrameworkViewResultPageInterceptor->renderResult() called at [lib/internal/Magento/Framework/App/Http.php:140]
    #90 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
    #91 MagentoFrameworkAppHttpInterceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:258]
    #92 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:40]
    </pre>


    It seems that for override this file, something is still missing.



    The renderer.phtml file I want override is currently the same as the original. Here is the content:



    <?php
    /**
    * Copyright © Magento, Inc. All rights reserved.
    * See COPYING.txt for license details.
    */

    // @codingStandardsIgnoreFile

    /** @var $block MagentoSwatchesBlockLayeredNavigationRenderLayered */
    ?>
    <?php $swatchData = $block->getSwatchData(); ?>
    <div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
    attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
    attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
    <div class="swatch-attribute-options clearfix">
    <?php foreach ($swatchData['options'] as $option => $label): ?>
    <a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
    aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
    class="swatch-option-link-layered">
    <?php if (isset($swatchData['swatches'][$option]['type'])) ?>
    <?php switch ($swatchData['swatches'][$option]['type'])
    case '3':
    ?>
    <div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
    tabindex="-1"
    option-type="3"
    option-id="<?= /* @escapeNotVerified */ $option ?>"
    option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
    option-tooltip-thumb=""
    option-tooltip-value=""
    ></div>
    <?php break;
    case '2':
    ?>
    <?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
    $swatchData['swatches'][$option]['value']); ?>
    <?php $swatchImagePath = $block->getSwatchPath('swatch_image',
    $swatchData['swatches'][$option]['value']); ?>
    <div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
    tabindex="-1"
    option-type="2"
    option-id="<?= /* @escapeNotVerified */ $option ?>"
    option-label="BB<?= /* @escapeNotVerified */ $label['label'] ?>"
    option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
    option-tooltip-value=""
    style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
    <?php break;
    case '1':
    ?>
    <div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
    tabindex="-1"
    option-type="1"
    option-id="<?= /* @escapeNotVerified */ $option ?>"
    option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
    option-tooltip-thumb=""
    option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
    style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
    <?php break;
    case '0':
    default:
    ?>
    <div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
    tabindex="-1"
    option-type="0"
    option-id="<?= /* @escapeNotVerified */ $option ?>"
    option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
    option-tooltip-thumb=""
    option-tooltip-value=""
    ><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
    <?php break;
    ?>
    <?php ?>
    </a>
    <?php endforeach; ?>
    </div>
    </div>

    <script>
    require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($)
    $('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
    .find('[option-type="1"], [option-type="2"], [option-type="0"], [option-type="3"]')
    .SwatchRendererTooltip();
    );
    </script>


    I would like to modify the "case '2'".



    How can I proceed ?
    I suppose I have to import this file in renderer.phtml :
    MagentoSwatchesBlockLayeredNavigationRenderLayered



    But I would like to do it by the better way.



    Thanks !






    share|improve this answer










    New contributor




    Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Jimmy Labuche is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272693%2fmagento-2-override-swatches-renderer-phtml%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      If you want to customize in product listing page. Kindly override in the following path




      app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/listing/renderer.phtml




      If you want to customize in product detail page. Kindly override in the following path




      app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/view/renderer.phtml







      share|improve this answer



























        0














        If you want to customize in product listing page. Kindly override in the following path




        app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/listing/renderer.phtml




        If you want to customize in product detail page. Kindly override in the following path




        app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/view/renderer.phtml







        share|improve this answer

























          0












          0








          0







          If you want to customize in product listing page. Kindly override in the following path




          app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/listing/renderer.phtml




          If you want to customize in product detail page. Kindly override in the following path




          app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/view/renderer.phtml







          share|improve this answer













          If you want to customize in product listing page. Kindly override in the following path




          app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/listing/renderer.phtml




          If you want to customize in product detail page. Kindly override in the following path




          app/design/frontend/[VendorName]/[theme]/Magento_Swatches/templates/product/view/renderer.phtml








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          ARUNPRABAKARAN MARUNPRABAKARAN M

          641114




          641114























              0














              Thanks @ARUNPRABAKARAN-M,



              I think this is the good solution cause now I've an error on product page.



              Please see below :



              1 exception(s):
              Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16

              Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16
              <pre>#1 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
              #2 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
              #3 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:609]
              #4 MagentoSwatchesBlockProductRendererConfigurableInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
              #5 MagentoFrameworkViewElementTemplate->_toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:461]
              #6 MagentoSwatchesBlockProductRendererConfigurable->getHtmlOutput() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:439]
              #7 MagentoSwatchesBlockProductRendererConfigurable->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
              #8 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:429]
              #9 MagentoSwatchesBlockProductRendererConfigurable->toHtml() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:89]
              #10 MagentoSwatchesBlockProductRendererConfigurableInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
              #11 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
              #12 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #13 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #14 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #15 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:512]
              #16 MagentoFrameworkViewElementAbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:778]
              #17 MagentoCatalogBlockProductViewInterceptor->getChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/options/wrapper.phtml:15]
              #18 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
              #19 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
              #20 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
              #21 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
              #22 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
              #23 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
              #24 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
              #25 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
              #26 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #27 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #28 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #29 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:543]
              #30 MagentoFrameworkViewElementAbstractBlock->getChildChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:791]
              #31 MagentoCatalogBlockProductViewInterceptor->getChildChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml:32]
              #32 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
              #33 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
              #34 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
              #35 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
              #36 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
              #37 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
              #38 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
              #39 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
              #40 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #41 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #42 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #43 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #44 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #45 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #46 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #47 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #48 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #49 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #50 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #51 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #52 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #53 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #54 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #55 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #56 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #57 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #58 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #59 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #60 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #61 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #62 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #63 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #64 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #65 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #66 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #67 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #68 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #69 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #70 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #71 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #72 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #73 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
              #74 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
              #75 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
              #76 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
              #77 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
              #78 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:954]
              #79 MagentoFrameworkViewLayout->getOutput() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
              #80 MagentoFrameworkViewLayoutInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
              #81 MagentoFrameworkViewLayoutInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
              #82 MagentoFrameworkViewLayoutInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
              #83 MagentoFrameworkViewLayoutInterceptor->getOutput() called at [lib/internal/Magento/Framework/View/Result/Page.php:258]
              #84 MagentoFrameworkViewResultPage->render() called at [lib/internal/Magento/Framework/View/Result/Layout.php:171]
              #85 MagentoFrameworkViewResultLayout->renderResult() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
              #86 MagentoFrameworkViewResultPageInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
              #87 MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
              #88 MagentoFrameworkViewResultPageInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
              #89 MagentoFrameworkViewResultPageInterceptor->renderResult() called at [lib/internal/Magento/Framework/App/Http.php:140]
              #90 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
              #91 MagentoFrameworkAppHttpInterceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:258]
              #92 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:40]
              </pre>


              It seems that for override this file, something is still missing.



              The renderer.phtml file I want override is currently the same as the original. Here is the content:



              <?php
              /**
              * Copyright © Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */

              // @codingStandardsIgnoreFile

              /** @var $block MagentoSwatchesBlockLayeredNavigationRenderLayered */
              ?>
              <?php $swatchData = $block->getSwatchData(); ?>
              <div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
              attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
              attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
              <div class="swatch-attribute-options clearfix">
              <?php foreach ($swatchData['options'] as $option => $label): ?>
              <a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
              aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
              class="swatch-option-link-layered">
              <?php if (isset($swatchData['swatches'][$option]['type'])) ?>
              <?php switch ($swatchData['swatches'][$option]['type'])
              case '3':
              ?>
              <div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
              tabindex="-1"
              option-type="3"
              option-id="<?= /* @escapeNotVerified */ $option ?>"
              option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
              option-tooltip-thumb=""
              option-tooltip-value=""
              ></div>
              <?php break;
              case '2':
              ?>
              <?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
              $swatchData['swatches'][$option]['value']); ?>
              <?php $swatchImagePath = $block->getSwatchPath('swatch_image',
              $swatchData['swatches'][$option]['value']); ?>
              <div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
              tabindex="-1"
              option-type="2"
              option-id="<?= /* @escapeNotVerified */ $option ?>"
              option-label="BB<?= /* @escapeNotVerified */ $label['label'] ?>"
              option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
              option-tooltip-value=""
              style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
              <?php break;
              case '1':
              ?>
              <div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
              tabindex="-1"
              option-type="1"
              option-id="<?= /* @escapeNotVerified */ $option ?>"
              option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
              option-tooltip-thumb=""
              option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
              style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
              <?php break;
              case '0':
              default:
              ?>
              <div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
              tabindex="-1"
              option-type="0"
              option-id="<?= /* @escapeNotVerified */ $option ?>"
              option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
              option-tooltip-thumb=""
              option-tooltip-value=""
              ><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
              <?php break;
              ?>
              <?php ?>
              </a>
              <?php endforeach; ?>
              </div>
              </div>

              <script>
              require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($)
              $('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
              .find('[option-type="1"], [option-type="2"], [option-type="0"], [option-type="3"]')
              .SwatchRendererTooltip();
              );
              </script>


              I would like to modify the "case '2'".



              How can I proceed ?
              I suppose I have to import this file in renderer.phtml :
              MagentoSwatchesBlockLayeredNavigationRenderLayered



              But I would like to do it by the better way.



              Thanks !






              share|improve this answer










              New contributor




              Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                Thanks @ARUNPRABAKARAN-M,



                I think this is the good solution cause now I've an error on product page.



                Please see below :



                1 exception(s):
                Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16

                Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16
                <pre>#1 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                #2 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                #3 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:609]
                #4 MagentoSwatchesBlockProductRendererConfigurableInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                #5 MagentoFrameworkViewElementTemplate->_toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:461]
                #6 MagentoSwatchesBlockProductRendererConfigurable->getHtmlOutput() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:439]
                #7 MagentoSwatchesBlockProductRendererConfigurable->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                #8 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:429]
                #9 MagentoSwatchesBlockProductRendererConfigurable->toHtml() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:89]
                #10 MagentoSwatchesBlockProductRendererConfigurableInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                #11 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                #12 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #13 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #14 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #15 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:512]
                #16 MagentoFrameworkViewElementAbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:778]
                #17 MagentoCatalogBlockProductViewInterceptor->getChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/options/wrapper.phtml:15]
                #18 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                #19 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                #20 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                #21 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                #22 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                #23 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                #24 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                #25 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                #26 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #27 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #28 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #29 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:543]
                #30 MagentoFrameworkViewElementAbstractBlock->getChildChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:791]
                #31 MagentoCatalogBlockProductViewInterceptor->getChildChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml:32]
                #32 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                #33 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                #34 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                #35 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                #36 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                #37 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                #38 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                #39 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                #40 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #41 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #42 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #43 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #44 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #45 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #46 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #47 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #48 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #49 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #50 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #51 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #52 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #53 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #54 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #55 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #56 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #57 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #58 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #59 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #60 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #61 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #62 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #63 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #64 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #65 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #66 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #67 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #68 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #69 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #70 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #71 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #72 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #73 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                #74 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                #75 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                #76 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                #77 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                #78 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:954]
                #79 MagentoFrameworkViewLayout->getOutput() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                #80 MagentoFrameworkViewLayoutInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                #81 MagentoFrameworkViewLayoutInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                #82 MagentoFrameworkViewLayoutInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
                #83 MagentoFrameworkViewLayoutInterceptor->getOutput() called at [lib/internal/Magento/Framework/View/Result/Page.php:258]
                #84 MagentoFrameworkViewResultPage->render() called at [lib/internal/Magento/Framework/View/Result/Layout.php:171]
                #85 MagentoFrameworkViewResultLayout->renderResult() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                #86 MagentoFrameworkViewResultPageInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                #87 MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                #88 MagentoFrameworkViewResultPageInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
                #89 MagentoFrameworkViewResultPageInterceptor->renderResult() called at [lib/internal/Magento/Framework/App/Http.php:140]
                #90 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
                #91 MagentoFrameworkAppHttpInterceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:258]
                #92 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:40]
                </pre>


                It seems that for override this file, something is still missing.



                The renderer.phtml file I want override is currently the same as the original. Here is the content:



                <?php
                /**
                * Copyright © Magento, Inc. All rights reserved.
                * See COPYING.txt for license details.
                */

                // @codingStandardsIgnoreFile

                /** @var $block MagentoSwatchesBlockLayeredNavigationRenderLayered */
                ?>
                <?php $swatchData = $block->getSwatchData(); ?>
                <div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
                <div class="swatch-attribute-options clearfix">
                <?php foreach ($swatchData['options'] as $option => $label): ?>
                <a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
                aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                class="swatch-option-link-layered">
                <?php if (isset($swatchData['swatches'][$option]['type'])) ?>
                <?php switch ($swatchData['swatches'][$option]['type'])
                case '3':
                ?>
                <div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                tabindex="-1"
                option-type="3"
                option-id="<?= /* @escapeNotVerified */ $option ?>"
                option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                option-tooltip-thumb=""
                option-tooltip-value=""
                ></div>
                <?php break;
                case '2':
                ?>
                <?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
                $swatchData['swatches'][$option]['value']); ?>
                <?php $swatchImagePath = $block->getSwatchPath('swatch_image',
                $swatchData['swatches'][$option]['value']); ?>
                <div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                tabindex="-1"
                option-type="2"
                option-id="<?= /* @escapeNotVerified */ $option ?>"
                option-label="BB<?= /* @escapeNotVerified */ $label['label'] ?>"
                option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
                option-tooltip-value=""
                style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
                <?php break;
                case '1':
                ?>
                <div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                tabindex="-1"
                option-type="1"
                option-id="<?= /* @escapeNotVerified */ $option ?>"
                option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                option-tooltip-thumb=""
                option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
                style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
                <?php break;
                case '0':
                default:
                ?>
                <div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                tabindex="-1"
                option-type="0"
                option-id="<?= /* @escapeNotVerified */ $option ?>"
                option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                option-tooltip-thumb=""
                option-tooltip-value=""
                ><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
                <?php break;
                ?>
                <?php ?>
                </a>
                <?php endforeach; ?>
                </div>
                </div>

                <script>
                require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($)
                $('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
                .find('[option-type="1"], [option-type="2"], [option-type="0"], [option-type="3"]')
                .SwatchRendererTooltip();
                );
                </script>


                I would like to modify the "case '2'".



                How can I proceed ?
                I suppose I have to import this file in renderer.phtml :
                MagentoSwatchesBlockLayeredNavigationRenderLayered



                But I would like to do it by the better way.



                Thanks !






                share|improve this answer










                New contributor




                Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  Thanks @ARUNPRABAKARAN-M,



                  I think this is the good solution cause now I've an error on product page.



                  Please see below :



                  1 exception(s):
                  Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16

                  Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16
                  <pre>#1 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #2 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #3 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:609]
                  #4 MagentoSwatchesBlockProductRendererConfigurableInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #5 MagentoFrameworkViewElementTemplate->_toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:461]
                  #6 MagentoSwatchesBlockProductRendererConfigurable->getHtmlOutput() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:439]
                  #7 MagentoSwatchesBlockProductRendererConfigurable->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #8 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:429]
                  #9 MagentoSwatchesBlockProductRendererConfigurable->toHtml() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:89]
                  #10 MagentoSwatchesBlockProductRendererConfigurableInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #11 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #12 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #13 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #14 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #15 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:512]
                  #16 MagentoFrameworkViewElementAbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:778]
                  #17 MagentoCatalogBlockProductViewInterceptor->getChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/options/wrapper.phtml:15]
                  #18 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #19 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #20 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                  #21 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #22 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #23 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                  #24 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #25 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #26 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #27 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #28 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #29 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:543]
                  #30 MagentoFrameworkViewElementAbstractBlock->getChildChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:791]
                  #31 MagentoCatalogBlockProductViewInterceptor->getChildChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml:32]
                  #32 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #33 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #34 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                  #35 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #36 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #37 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                  #38 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #39 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #40 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #41 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #42 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #43 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #44 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #45 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #46 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #47 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #48 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #49 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #50 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #51 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #52 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #53 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #54 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #55 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #56 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #57 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #58 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #59 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #60 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #61 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #62 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #63 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #64 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #65 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #66 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #67 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #68 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #69 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #70 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #71 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #72 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #73 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #74 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #75 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #76 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #77 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #78 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:954]
                  #79 MagentoFrameworkViewLayout->getOutput() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                  #80 MagentoFrameworkViewLayoutInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                  #81 MagentoFrameworkViewLayoutInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                  #82 MagentoFrameworkViewLayoutInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
                  #83 MagentoFrameworkViewLayoutInterceptor->getOutput() called at [lib/internal/Magento/Framework/View/Result/Page.php:258]
                  #84 MagentoFrameworkViewResultPage->render() called at [lib/internal/Magento/Framework/View/Result/Layout.php:171]
                  #85 MagentoFrameworkViewResultLayout->renderResult() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                  #86 MagentoFrameworkViewResultPageInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                  #87 MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                  #88 MagentoFrameworkViewResultPageInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
                  #89 MagentoFrameworkViewResultPageInterceptor->renderResult() called at [lib/internal/Magento/Framework/App/Http.php:140]
                  #90 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
                  #91 MagentoFrameworkAppHttpInterceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:258]
                  #92 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:40]
                  </pre>


                  It seems that for override this file, something is still missing.



                  The renderer.phtml file I want override is currently the same as the original. Here is the content:



                  <?php
                  /**
                  * Copyright © Magento, Inc. All rights reserved.
                  * See COPYING.txt for license details.
                  */

                  // @codingStandardsIgnoreFile

                  /** @var $block MagentoSwatchesBlockLayeredNavigationRenderLayered */
                  ?>
                  <?php $swatchData = $block->getSwatchData(); ?>
                  <div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                  attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                  attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
                  <div class="swatch-attribute-options clearfix">
                  <?php foreach ($swatchData['options'] as $option => $label): ?>
                  <a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
                  aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  class="swatch-option-link-layered">
                  <?php if (isset($swatchData['swatches'][$option]['type'])) ?>
                  <?php switch ($swatchData['swatches'][$option]['type'])
                  case '3':
                  ?>
                  <div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="3"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value=""
                  ></div>
                  <?php break;
                  case '2':
                  ?>
                  <?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
                  $swatchData['swatches'][$option]['value']); ?>
                  <?php $swatchImagePath = $block->getSwatchPath('swatch_image',
                  $swatchData['swatches'][$option]['value']); ?>
                  <div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="2"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="BB<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
                  option-tooltip-value=""
                  style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
                  <?php break;
                  case '1':
                  ?>
                  <div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="1"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
                  style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
                  <?php break;
                  case '0':
                  default:
                  ?>
                  <div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="0"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value=""
                  ><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
                  <?php break;
                  ?>
                  <?php ?>
                  </a>
                  <?php endforeach; ?>
                  </div>
                  </div>

                  <script>
                  require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($)
                  $('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
                  .find('[option-type="1"], [option-type="2"], [option-type="0"], [option-type="3"]')
                  .SwatchRendererTooltip();
                  );
                  </script>


                  I would like to modify the "case '2'".



                  How can I proceed ?
                  I suppose I have to import this file in renderer.phtml :
                  MagentoSwatchesBlockLayeredNavigationRenderLayered



                  But I would like to do it by the better way.



                  Thanks !






                  share|improve this answer










                  New contributor




                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  Thanks @ARUNPRABAKARAN-M,



                  I think this is the good solution cause now I've an error on product page.



                  Please see below :



                  1 exception(s):
                  Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16

                  Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/jkcmage/app/design/frontend/Smartwave/porto_child/Magento_Swatches/templates/product/view/renderer.phtml on line 16
                  <pre>#1 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #2 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #3 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:609]
                  #4 MagentoSwatchesBlockProductRendererConfigurableInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #5 MagentoFrameworkViewElementTemplate->_toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:461]
                  #6 MagentoSwatchesBlockProductRendererConfigurable->getHtmlOutput() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:439]
                  #7 MagentoSwatchesBlockProductRendererConfigurable->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #8 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php:429]
                  #9 MagentoSwatchesBlockProductRendererConfigurable->toHtml() called at [generated/code/Magento/Swatches/Block/Product/Renderer/Configurable/Interceptor.php:89]
                  #10 MagentoSwatchesBlockProductRendererConfigurableInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #11 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #12 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #13 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #14 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #15 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:512]
                  #16 MagentoFrameworkViewElementAbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:778]
                  #17 MagentoCatalogBlockProductViewInterceptor->getChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/options/wrapper.phtml:15]
                  #18 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #19 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #20 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                  #21 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #22 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #23 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                  #24 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #25 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #26 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #27 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #28 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #29 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:543]
                  #30 MagentoFrameworkViewElementAbstractBlock->getChildChildHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:791]
                  #31 MagentoCatalogBlockProductViewInterceptor->getChildChildHtml() called at [app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml:32]
                  #32 include() called at [lib/internal/Magento/Framework/View/TemplateEngine/Php.php:59]
                  #33 MagentoFrameworkViewTemplateEnginePhp->render() called at [lib/internal/Magento/Framework/View/Element/Template.php:271]
                  #34 MagentoFrameworkViewElementTemplate->fetchView() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:544]
                  #35 MagentoCatalogBlockProductViewInterceptor->fetchView() called at [lib/internal/Magento/Framework/View/Element/Template.php:301]
                  #36 MagentoFrameworkViewElementTemplate->_toHtml() called at [lib/internal/Magento/Framework/View/Element/AbstractBlock.php:668]
                  #37 MagentoFrameworkViewElementAbstractBlock->toHtml() called at [generated/code/Magento/Catalog/Block/Product/View/Interceptor.php:869]
                  #38 MagentoCatalogBlockProductViewInterceptor->toHtml() called at [lib/internal/Magento/Framework/View/Layout.php:557]
                  #39 MagentoFrameworkViewLayout->_renderBlock() called at [lib/internal/Magento/Framework/View/Layout.php:533]
                  #40 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #41 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #42 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #43 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #44 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #45 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #46 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #47 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #48 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #49 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #50 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #51 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #52 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #53 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #54 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #55 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #56 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #57 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #58 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #59 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #60 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #61 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #62 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #63 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #64 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #65 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #66 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #67 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #68 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #69 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #70 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #71 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #72 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #73 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:585]
                  #74 MagentoFrameworkViewLayout->_renderContainer() called at [lib/internal/Magento/Framework/View/Layout.php:535]
                  #75 MagentoFrameworkViewLayout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
                  #76 MagentoFrameworkViewLayoutInterceptor->renderNonCachedElement() called at [lib/internal/Magento/Framework/View/Layout.php:488]
                  #77 MagentoFrameworkViewLayout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
                  #78 MagentoFrameworkViewLayoutInterceptor->renderElement() called at [lib/internal/Magento/Framework/View/Layout.php:954]
                  #79 MagentoFrameworkViewLayout->getOutput() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                  #80 MagentoFrameworkViewLayoutInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                  #81 MagentoFrameworkViewLayoutInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                  #82 MagentoFrameworkViewLayoutInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
                  #83 MagentoFrameworkViewLayoutInterceptor->getOutput() called at [lib/internal/Magento/Framework/View/Result/Page.php:258]
                  #84 MagentoFrameworkViewResultPage->render() called at [lib/internal/Magento/Framework/View/Result/Layout.php:171]
                  #85 MagentoFrameworkViewResultLayout->renderResult() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
                  #86 MagentoFrameworkViewResultPageInterceptor->___callParent() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
                  #87 MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterceptionclosure() called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
                  #88 MagentoFrameworkViewResultPageInterceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
                  #89 MagentoFrameworkViewResultPageInterceptor->renderResult() called at [lib/internal/Magento/Framework/App/Http.php:140]
                  #90 MagentoFrameworkAppHttp->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
                  #91 MagentoFrameworkAppHttpInterceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:258]
                  #92 MagentoFrameworkAppBootstrap->run() called at [pub/index.php:40]
                  </pre>


                  It seems that for override this file, something is still missing.



                  The renderer.phtml file I want override is currently the same as the original. Here is the content:



                  <?php
                  /**
                  * Copyright © Magento, Inc. All rights reserved.
                  * See COPYING.txt for license details.
                  */

                  // @codingStandardsIgnoreFile

                  /** @var $block MagentoSwatchesBlockLayeredNavigationRenderLayered */
                  ?>
                  <?php $swatchData = $block->getSwatchData(); ?>
                  <div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                  attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
                  attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
                  <div class="swatch-attribute-options clearfix">
                  <?php foreach ($swatchData['options'] as $option => $label): ?>
                  <a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
                  aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  class="swatch-option-link-layered">
                  <?php if (isset($swatchData['swatches'][$option]['type'])) ?>
                  <?php switch ($swatchData['swatches'][$option]['type'])
                  case '3':
                  ?>
                  <div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="3"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value=""
                  ></div>
                  <?php break;
                  case '2':
                  ?>
                  <?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
                  $swatchData['swatches'][$option]['value']); ?>
                  <?php $swatchImagePath = $block->getSwatchPath('swatch_image',
                  $swatchData['swatches'][$option]['value']); ?>
                  <div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="2"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="BB<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
                  option-tooltip-value=""
                  style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
                  <?php break;
                  case '1':
                  ?>
                  <div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="1"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
                  style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
                  <?php break;
                  case '0':
                  default:
                  ?>
                  <div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
                  tabindex="-1"
                  option-type="0"
                  option-id="<?= /* @escapeNotVerified */ $option ?>"
                  option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
                  option-tooltip-thumb=""
                  option-tooltip-value=""
                  ><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
                  <?php break;
                  ?>
                  <?php ?>
                  </a>
                  <?php endforeach; ?>
                  </div>
                  </div>

                  <script>
                  require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($)
                  $('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
                  .find('[option-type="1"], [option-type="2"], [option-type="0"], [option-type="3"]')
                  .SwatchRendererTooltip();
                  );
                  </script>


                  I would like to modify the "case '2'".



                  How can I proceed ?
                  I suppose I have to import this file in renderer.phtml :
                  MagentoSwatchesBlockLayeredNavigationRenderLayered



                  But I would like to do it by the better way.



                  Thanks !







                  share|improve this answer










                  New contributor




                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited 13 hours ago





















                  New contributor




                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 13 hours ago









                  Jimmy LabucheJimmy Labuche

                  64




                  64




                  New contributor




                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Jimmy Labuche is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.




















                      Jimmy Labuche is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Jimmy Labuche is a new contributor. Be nice, and check out our Code of Conduct.












                      Jimmy Labuche is a new contributor. Be nice, and check out our Code of Conduct.











                      Jimmy Labuche is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272693%2fmagento-2-override-swatches-renderer-phtml%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?