Jump to content
thirty bees forum
  • 0

Override not working for Category field added


zen

Question

Hello,

I did add a short_description field for each category in class and controller admin, it works instantly.

Then I moved the code to do an override, after several hours it never worked.. I don't understand what is going on, as for products it works good with same technique overriding.

The mystery remains 😞

TB version 1.5.1, on php 8 on a fresh install.

Best regards.

 

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
Posted (edited)
16 minutes ago, yaniv14 said:

did you delete the cache/class_index file?

Yes indeed.

I am used to make overrides and usually it works.. but here on this 1.5.1 version it's a real mystery..

as it does nothing different thant the core code except error if the code or syntax is wrong.

Thank you for your interrest @yaniv14

Edited by zen
Link to comment
Share on other sites

  • 0
17 minutes ago, datakick said:

that will be php8 issue, most likely this fix:https://github.com/thirtybees/thirtybees/commit/5de5f96760f01e5addbb5c045608c7dc5e863799

 

Update to 1.6

I was suspecting something like this, but as the code is for PHP8 I didn't even try to change php version.

Now I did update with coreupdater to bleeding edge 1.6.0 version and I create proper overrides.. and nothing happen, super strange  😞 😞 

BUT for this case I don't need override anymore, as you did insert the additional_description for category as it has been done on Presta 8.x, well DONE !! 

 

 

Link to comment
Share on other sites

  • 0
Posted (edited)

Now on this version, like on many other website with different TB and PHP version I got this warning in Core Updater :

Changed files

  • config/smarty.config.inc.php modified
Edited by zen
Link to comment
Share on other sites

  • 0
1 hour ago, zen said:

....as you did insert the additional_description for category as it has been done on Presta 8.x, well DONE !! 

Do you have an picture about this, please?  I really want to see this details, as it is interesting for us since a long time and we did not get managed an solution. 

Link to comment
Share on other sites

  • 0
2 hours ago, DRMasterChief said:

Do you have an picture about this, please?  I really want to see this details, as it is interesting for us since a long time and we did not get managed an solution. 

Simply try TB 1.6.0 version and create or edit a category, you will find a new field for additional_description that can be used in front page, to have 2 descriptions on category page, like a short and long one.. then you can manage that in your theme to suits your needs for SEO and design.

Link to comment
Share on other sites

  • 0
15 hours ago, zen said:

Now I did update with coreupdater to bleeding edge 1.6.0 version and I create proper overrides.. and nothing happen, super strange  😞 😞 

Could you please share your override, so I can test? It should be still possible to override object model metadata

10 hours ago, DRMasterChief said:

ok, maybe i have to set up a new test ecosphere with tb 1.6  🙂   -  i thought a short screenshot of this will help us all.

It's a simple change, new html field in back office:

image.png.06d0a634ce3225558bc171afa824474a.png

 

You will probably have to modify your theme to display this new field. Simply edit category.tpl file and include this new field at the place you want. You can take an inspiration from niara support commit: https://github.com/thirtybees/niara/commit/beedd63032237293b2be1d5fe1463144d2f82e12

 

image.png.2cb66e464a78e2ef778283f9882cab43.png

 

 

  • Thanks 1
Link to comment
Share on other sites

  • 0
22 minutes ago, zen said:

Here is the file override/controllers/admin/AdminCategoriesController.php

with a new filed 'short_description' before 'description'.

 

AdminCategoriesController.php 16.54 kB · 0 downloads

It didn't work because your changes were overwritten by core.

For example, in constructor, you assigned some data to fields_list variable, and THEN you called paren constuctor. Parent constructor assign it's own data to fields_list variable

    public function __construct()
    {       
        $this->fields_list = [
	    // you changes to fields_list
        ];
        parent::__construct(); // this call overwrites the fields_list
    }

You should have called the constructor first, and then merge your changes:

   public function __construct()
    {  
        parent::__construct();

        $this->fields_list = array_merge($this->fields_list, [ 
	    // you changes to fields_list
        ]);
    }

 

  • Thanks 1
Link to comment
Share on other sites

  • 0

I make an override of Category class and it works fine, the parent::__construct() was in first position like you show on core file already.

Now I noticed something : when on back office on a category edit page, you can upload images for MENU only if the module block categories is activated, it seems strange, is there any reason for that ?

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...