- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How and where i can override to change the limit of characters in product name in catalog page?
Like i have a product name as ABCDEFGHIJK and this took like 2 lines of words
i want to be shown only ABCD... for an example
Can someone help me?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @eCom_Microware
<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?> you need to change here:-
<?php /* @escapeNotVerified */ $name = $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
<?php echo $name = strlen($name ) > 50 ? substr($name ,0,50)."..." : $name ;?>
if you are using any theme then you need to change into
app/design/frontend/YourTHemePackageName/ThemeName/Magento_Catalog/templates/product/list.phtml
hope it will help you
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Hello @eCom_Microware
you need to apply below css for this
p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 75ch; }
you need to add your class, hope it will help you.
If works then mark as a solution.
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Hi thanks for your quickly reply
There is a way to make the maximum lines to 2?
Above is inserting your code.
I want something like this
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
i am not able see your screenshot, please share via some onlline tool
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
You can see both images in imgur
The first one is with your code
The second one is the way i need
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Hello @eCom_Microware
you can just adjust max width
hope it will help you, if works then mark as a solution.
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Over 186px nothing changes, because using white-space nowrap, the text only appears in one line.
I Think using css is impossible to do that, maybe override a file in cores files
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Hello @eCom_Microware
you need to do using php if you need into two lines
$out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;
where you need to increase 50 to whatever you wants.
hope it will help you, if works then mark as a solution.
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Limit of Product Name in Product Catalog Magento 2.3
Thanks again,
i know that, but i dunno where to insert this code to work properly, can u help me?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @eCom_Microware
<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?> you need to change here:-
<?php /* @escapeNotVerified */ $name = $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
<?php echo $name = strlen($name ) > 50 ? substr($name ,0,50)."..." : $name ;?>
if you are using any theme then you need to change into
app/design/frontend/YourTHemePackageName/ThemeName/Magento_Catalog/templates/product/list.phtml
hope it will help you
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer