Jump to content

How to override classes with a namespace?


Kevin

Recommended Posts

Hi,

 

I would like to override the class Category.php, the function getSubCategories with a custom order by.

Problem is that Category.php extends the ObjectModel that has a namespace and these classes cannot be overridden.

So my question is, how can i achieve what i want without modifying the core file Category.php?

Thanks!

Kevin

Link to comment
Share on other sites

Hi,

I don't see any issue in overriding the Category.php (class). Just create the file Category.php inside the override/classes folder.

Check the below code for reference.

class Category extends CategoryCore
{
	public function getSubCategories($idLang, $active = true)
    {
		//Do whatever you want to do.
	}
}

 

Edited by Knowband Plugins (see edit history)
Link to comment
Share on other sites

2 minutes ago, Knowband Plugins said:

Hi,

I don't see any issue in overriding the Category.php (class). Just create the file Category.php insider the override/classes folder.

Check the below code for reference.


class Category extends CategoryCore
{
	public function getSubCategories($idLang, $active = true)
    {
		//Do whatever you want to do.
	}
}

 

That is exactely what i did, but that doesn't work. app/cache folder is not present(cache is turned off) so cannot delete that file.

Link to comment
Share on other sites

Kindly confirm in which folder you have placed the file? Means you have placed the file directly inside the ROOT/override/classes OR it's inside the module override folder?

In case of module override folder, you need to reset the module (if the module is already installed) to reflect the changes (As the system will place the override file from module override folder to ROOT/override/classes on installation/Reset).

 

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