Answers for "Magento 2 -Limit the length of the product name on the front end."

PHP
2

Magento 2 -Limit the length of the product name on the front end.

<?php
$productName = $_helper->productAttribute($_product, $_product->getName(), 'name');
$len = strlen($productName);
?>
<a class="product-item-link" href="<?php echo /* @escapeNotVerified */ $_product->getProductUrl() ?>">
    <?php echo substr($productName,0,50); ?>
    <?php if($len > 50) echo '...'; ?>
</a>
Posted by: Guest on August-24-2021

Code answers related to "Magento 2 -Limit the length of the product name on the front end."

Browse Popular Code Answers by Language