1
  <div class="product-item-details">
                            <strong class="product-item-name">
                                <a title="<?= $block->escapeHtml($item->getName()) ?>"
                                   href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>"
                                   class="product-item-link">
                                    <?= $block->escapeHtml($item->getName()) ?>
                                </a>

I'm trying to use substr like this

substr($_helper->productAttribute($_product, $_product->getName() , 'name'),0,75)

But my code does not work correctly, it shows a 504 on product page.

Thanks

1

In your code, you are using $_product while in the code you pasted product seems to be $item

Try changing:

substr($_helper->productAttribute($_product, $_product->getName() , 'name'),0,75)

To

substr($_helper->productAttribute($item, $item->getName() , 'name'),0,75)

  • Thanks works perfectly – Mmanza Sep 3 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.