0

I've added extra columns for my module in the product grid. Within the columns, I'm inserting some of my own icons that contain anchor tag links. When I click on the icons, I'm taken to the product edit page instead of the link I've specified in the icon, which is the default behavior when you click on a row in the product grid.

How do we override the product grid's default links so I can use my own specified links?

I've tried the JavaScript preventDefault() method to no avail, but I'm sure I'm using it correctly.

1 Answer 1

1

You can override this file to made your changes:

From:

vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/viewmode.phtml

To:

app/design/frontend/YourPackage/YourTheme/Magento_Catalog/templates/product/list/toolbar/viewmode.phtml

If you want to change or increase a new method you need create a module or a plugin that change the class:

vendor/magento/module-catalog/Model/Product/ProductList/Toolbar.php
8
  • Thanks for your help Rafael. Is there a way that I can override the links within my own code, i. e. app/code, instead of changing the files you mention? May 31, 2017 at 14:42
  • Also, I'm sure if I understand completely. To test, I deleted everything in vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/viewmode.phtml, and deleted all cache, but nothing changed within the product grid. May 31, 2017 at 15:13
  • Check the path app/design/frontend/YourPackage/YourTheme if it's in your custom theme. You need to change the YourPackage and YourTheme. May 31, 2017 at 16:23
  • I actually don't have a custom theme in app/design/frontend. Are you saying I need to create a theme to override the links? May 31, 2017 at 16:51
  • Yes, or a module, the theme is easier. May 31, 2017 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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