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.
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
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.
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
i am not able see your screenshot, please share via some onlline tool
You can see both images in imgur
The first one is with your code
The second one is the way i need
Hello @eCom_Microware
you can just adjust max width
hope it will help you, if works then mark as a solution.
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
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.
Thanks again,
i know that, but i dunno where to insert this code to work properly, can u help me?
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