Magento2: How to add a text between swatch configure and swatch attribute name?How to configure Profiler in Magento 2?Create Visual Swatch AttributeMagento2 Custom EAV attribute text in layered navigationMagneto2 : Add color swatch attribute option with colorcode value programmaticallyMagento 2 Free Input Text Field AttributeMagento 2 - Setting “Text Swatch” or “Visual Swatch” does not work. Attribute still shows as dropdown on frontendMagento2 how to associate attribute options to exist attribute?magento 2 cannot add text swatch option via php codeHow to add custom text to all email templates?How can I have a product attribute with a source model as a swatch?
If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?
Why does this potentiometer in an op-amp feedback path cause noise when adjusted?
How were Martello towers supposed to work?
Sharing shapefile collection
How can a dictatorship government be beneficial to a dictator in a post-scarcity society?
What's the point of having a RAID 1 configuration over incremental backups to a secondary drive?
Convert BAM to properly paired FASTQ files
Do I have a right to cancel a purchase of foreign currency in the UK?
Misspelling my name on my mathematical publications
Should disabled buttons give feedback when clicked?
Historical experience as a guide to warship design?
How can I truly shut down ssh server?
How do we handle pauses in a dialogue?
Why isn't pressure filtration popular compared to vacuum filtration?
Why do we need common sense in AI?
What happens to unproductive professors?
How to befriend private nested class
Confirming the Identity of a (Friendly) Reviewer After the Reviews
Plotting a function defined by equation without closed form solution
Is there any word for "disobedience to God"?
What does the phrase "head down the rat's hole" mean here?
Does the Pole of Angling's command word require an action?
How will law be enforced if violence becomes impossible?
How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?
Magento2: How to add a text between swatch configure and swatch attribute name?
How to configure Profiler in Magento 2?Create Visual Swatch AttributeMagento2 Custom EAV attribute text in layered navigationMagneto2 : Add color swatch attribute option with colorcode value programmaticallyMagento 2 Free Input Text Field AttributeMagento 2 - Setting “Text Swatch” or “Visual Swatch” does not work. Attribute still shows as dropdown on frontendMagento2 how to associate attribute options to exist attribute?magento 2 cannot add text swatch option via php codeHow to add custom text to all email templates?How can I have a product attribute with a source model as a swatch?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am having trouble while creating a module that add a text between swatch configure and swatch attribute name load by default, I want to add it only on a specific swatch if I have more than one. And what if it an input. How Can I do that?
For exmaple: we have
[attribute name] [attribute configure]
I want to add a text between them
[attribute name] [text] [attribute configure]
How can I do this, thanks 
magento2 magento2.3 swatches
add a comment |
I am having trouble while creating a module that add a text between swatch configure and swatch attribute name load by default, I want to add it only on a specific swatch if I have more than one. And what if it an input. How Can I do that?
For exmaple: we have
[attribute name] [attribute configure]
I want to add a text between them
[attribute name] [text] [attribute configure]
How can I do this, thanks 
magento2 magento2.3 swatches
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02
add a comment |
I am having trouble while creating a module that add a text between swatch configure and swatch attribute name load by default, I want to add it only on a specific swatch if I have more than one. And what if it an input. How Can I do that?
For exmaple: we have
[attribute name] [attribute configure]
I want to add a text between them
[attribute name] [text] [attribute configure]
How can I do this, thanks 
magento2 magento2.3 swatches
I am having trouble while creating a module that add a text between swatch configure and swatch attribute name load by default, I want to add it only on a specific swatch if I have more than one. And what if it an input. How Can I do that?
For exmaple: we have
[attribute name] [attribute configure]
I want to add a text between them
[attribute name] [text] [attribute configure]
How can I do this, thanks 
magento2 magento2.3 swatches
magento2 magento2.3 swatches
edited Jul 2 at 9:11
Ravi Varma
3351 silver badge13 bronze badges
3351 silver badge13 bronze badges
asked Jul 2 at 6:33
sekirosekiro
135 bronze badges
135 bronze badges
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02
add a comment |
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02
add a comment |
1 Answer
1
active
oldest
votes
You can add below code in swatch-renderer.js
Override this file in your custom theme and add custom code in below funciton.
/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
_init: function ()
if (_.isEmpty(this.options.jsonConfig.images))
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
// to use it in events handlers instead of _LoadProductMedia()
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '')
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
this._sortAttributes();
this._RenderControls();
this._setPreSelectedGallery();
$(this.element).trigger('swatch.initialized');
else
console.log('SwatchRenderer: No input data received');
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
if ($(".swatch-attribute.color")[0])
$('.swatch-attribute.color').after('<span>Some text</span>');
,
Here 'Some text'
Now color is your specific swatch code. "You can add your attribute code here"
Please check this.
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this lineif ($(".swatch-attribute.color")[0])
– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>')it will place next to swatches attribute name. Thanks for your help
– sekiro
Jul 2 at 8:51
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f280381%2fmagento2-how-to-add-a-text-between-swatch-configure-and-swatch-attribute-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can add below code in swatch-renderer.js
Override this file in your custom theme and add custom code in below funciton.
/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
_init: function ()
if (_.isEmpty(this.options.jsonConfig.images))
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
// to use it in events handlers instead of _LoadProductMedia()
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '')
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
this._sortAttributes();
this._RenderControls();
this._setPreSelectedGallery();
$(this.element).trigger('swatch.initialized');
else
console.log('SwatchRenderer: No input data received');
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
if ($(".swatch-attribute.color")[0])
$('.swatch-attribute.color').after('<span>Some text</span>');
,
Here 'Some text'
Now color is your specific swatch code. "You can add your attribute code here"
Please check this.
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this lineif ($(".swatch-attribute.color")[0])
– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>')it will place next to swatches attribute name. Thanks for your help
– sekiro
Jul 2 at 8:51
|
show 1 more comment
You can add below code in swatch-renderer.js
Override this file in your custom theme and add custom code in below funciton.
/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
_init: function ()
if (_.isEmpty(this.options.jsonConfig.images))
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
// to use it in events handlers instead of _LoadProductMedia()
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '')
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
this._sortAttributes();
this._RenderControls();
this._setPreSelectedGallery();
$(this.element).trigger('swatch.initialized');
else
console.log('SwatchRenderer: No input data received');
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
if ($(".swatch-attribute.color")[0])
$('.swatch-attribute.color').after('<span>Some text</span>');
,
Here 'Some text'
Now color is your specific swatch code. "You can add your attribute code here"
Please check this.
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this lineif ($(".swatch-attribute.color")[0])
– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>')it will place next to swatches attribute name. Thanks for your help
– sekiro
Jul 2 at 8:51
|
show 1 more comment
You can add below code in swatch-renderer.js
Override this file in your custom theme and add custom code in below funciton.
/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
_init: function ()
if (_.isEmpty(this.options.jsonConfig.images))
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
// to use it in events handlers instead of _LoadProductMedia()
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '')
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
this._sortAttributes();
this._RenderControls();
this._setPreSelectedGallery();
$(this.element).trigger('swatch.initialized');
else
console.log('SwatchRenderer: No input data received');
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
if ($(".swatch-attribute.color")[0])
$('.swatch-attribute.color').after('<span>Some text</span>');
,
Here 'Some text'
Now color is your specific swatch code. "You can add your attribute code here"
Please check this.
You can add below code in swatch-renderer.js
Override this file in your custom theme and add custom code in below funciton.
/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
_init: function ()
if (_.isEmpty(this.options.jsonConfig.images))
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
// to use it in events handlers instead of _LoadProductMedia()
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '')
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
this._sortAttributes();
this._RenderControls();
this._setPreSelectedGallery();
$(this.element).trigger('swatch.initialized');
else
console.log('SwatchRenderer: No input data received');
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
if ($(".swatch-attribute.color")[0])
$('.swatch-attribute.color').after('<span>Some text</span>');
,
Here 'Some text'
Now color is your specific swatch code. "You can add your attribute code here"
Please check this.
edited Jul 2 at 8:25
answered Jul 2 at 7:55
Ravi SoniRavi Soni
1,0415 silver badges18 bronze badges
1,0415 silver badges18 bronze badges
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this lineif ($(".swatch-attribute.color")[0])
– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>')it will place next to swatches attribute name. Thanks for your help
– sekiro
Jul 2 at 8:51
|
show 1 more comment
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this lineif ($(".swatch-attribute.color")[0])
– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>')it will place next to swatches attribute name. Thanks for your help
– sekiro
Jul 2 at 8:51
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
and what if in a product there are many swatches how can I choose a specific swatch attribute and add some text to it. I can understand your code however, it work with every swatch attribute, but not with an individual swatch attribute
– sekiro
Jul 2 at 8:00
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Check now I have updated my code
– Ravi Soni
Jul 2 at 8:25
Oh thanks, I want to ask what is number 0 mean in this line
if ($(".swatch-attribute.color")[0])– sekiro
Jul 2 at 8:28
Oh thanks, I want to ask what is number 0 mean in this line
if ($(".swatch-attribute.color")[0])– sekiro
Jul 2 at 8:28
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
I add your code to my module however, it not display next to swatches attribute name it display under them
– sekiro
Jul 2 at 8:45
Oh. here I come to solution with your code.
$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>') it will place next to swatches attribute name. Thanks for your help– sekiro
Jul 2 at 8:51
Oh. here I come to solution with your code.
$('.swatch-attribute.color > .swatch-attribute-label').after('<span>Some text</span>') it will place next to swatches attribute name. Thanks for your help– sekiro
Jul 2 at 8:51
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f280381%2fmagento2-how-to-add-a-text-between-swatch-configure-and-swatch-attribute-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Do you want to load it by default OR on On click swatches? And also please add screen here what exactly you expect?
– Ravi Soni
Jul 2 at 6:38
I want to load it by default, but really do not know how to do it
– sekiro
Jul 2 at 6:39
Can you please add screenshot what do you want OR on which page?
– Ravi Soni
Jul 2 at 6:55
@RaviSoni I just add it, thanks
– sekiro
Jul 2 at 7:02