Jump to content

Add new function to class or change existing function in class in PrestaShop 1.5


fanta1977

Recommended Posts

Hy everybody.

 

I create few new modules and I'm trying to make them to be easy to install.

 

But I have few problems.

 

First question that I have is hove to on the easy way add u new function which does not exist to some class, specifically I'm trying to add a new function to class ShopUrl?

 

I put the class like this in ShopUrl.php in my modul in folder: override/classes/shop/

 

with code like this:

class ShopUrlCore extends ObjectModel
{
	public static function someFunctionl($id_parametar1, $id_parametar2)
	{
		$ res = ....
		return $res;		
	}
}

I know that my function work beacuse when I put her directly in orginal ShopUrl.php it works with no problem.

 

Second question is how to change some existing functions?

 

For example, I change some function which is ussually in Tools.php.

 

Now how to write only the part of code that will always on the easy way override existing function in Tools.php and not that I need override entire class?

 

Thanks in adwance for every help.

 

P.S. I read the manuall on PrestaShop pages but id does not have me no sence, so I need help from good people of this forum.

Link to comment
Share on other sites

I try to that but it does not work for me.

 

Ok, there is file ShopUrl.php whicch is located in folder classes/shop/ and content of class in that file begins like:

class ShopCore extends ObjectModel
{
...
}

Now I create my own file which I also call ShopUrl.php and I put code like you show me:

class ShopUrl extends ShopUrlCore
{
...
}

If there is no mistake in my code and steps until now (if there is please show me and tell me) I have two questins for you.

 

1. question is in which folder I should put my file ShopUrl.php in my module? Directly in override folder or in folder like this override/shop/ ?

 

2.question is how should I make a call from my module of my new created function in overriden folder?

I was trying like this:  ShopUrl::someFunction(parametar1,parametar2);

 

Thanks in adwance for any help

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