Jump to content

Override Admin Categories from 1.7.6


Kevin

Recommended Posts

Hi Guys,

 

Since 1.7.6 the AdminCategoriesController.php doesn't seemed to be used anymore. Therefore they use core functionality like the file src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php

But i cannot find a way how to override this and add an extra field to the category overview in the backend. For products you got the hooks you can use(listingModifier) but for the categories these hooks aren't there. Anyone has a suggestion?

Thanks!

Regards,
Kevin

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
  • 3 months later...

Hi, I'm experiencing exactly the same problem right now. Has a solution been found in the meantime?

My goal is to add an additional textarea field to the category form in the backoffice to create a second category description.

Since my PrestaShop version is 1.7.6.5, it seems not to be able anymore to override the controllers/admin/AdminCategoriesController.php class.
I also found the stackoverflow question linked above, but it seemed to me to be kind of incomplete, because on the one hand probably the new field has to be created in the database and on the other hand the hooks "actionAdminCategoriesControllerSaveAfter" and "actionAdminCategoriesFormModifier" do not seem to exist.

Edited by D.EINS (see edit history)
Link to comment
Share on other sites

I didn't test this yet, but i suppose it works since it works with manufacturers(which also don't have a controller anymore).

In your custom module create a hook function hookActionManufacturerGridPresenterModifier, in the categories case something like hookActionCategoryGridPresenterModifier(not 100% sure about this name). In that function you can modify the $params['presented_grid']['data'] which includes all grid data.

In your custom module, create a structure like this: /views/PrestaShop/Admin/Common/Grid/Blocks/

In that folder create a file table.html.twig and another folder Table

In that folder /views/PrestaShop/Admin/Common/Grid/Blocks/Table add filters_row.html.twig and headers_row.html.twig

 

Doing that you override the core files on this location: /src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/

To make sure you only change the twig files for the manufacturer(or category in this case) i've added this in the twig files: 

{% if grid.id == "manufacturer" %}

 

Hope this helps a bit.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...