Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

XC5 Problem overriding class with a module

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-10-2015, 11:14 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Question XC5 Problem overriding class with a module

Hi everyone,

I'm having problems with overriding the class \XLite\View\ItemsList\Product\Customer\Search with the function getData().

The original class and function still gets called.

What are the usual things I should check? Is there a restriction on certain classes that cannot be overridden?

Code:
class Search extends \XLite\View\ItemsList\Product\Customer\Search implements \XLite\Base\IDecorator { /** * Return products list * * @param \XLite\Core\CommonCell $cnd Search condition * @param boolean $countOnly Return items list or only its size OPTIONAL * * @return array|integer */ protected function getData(\XLite\Core\CommonCell $cnd, $countOnly = false) { return \XLite\Core\Database::getRepo('\XLite\Model\Product')->search( $cnd, $countOnly ); } }
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #2  
Old 03-11-2015, 03:49 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: XC5 Problem overriding class with a module

What is your name space? Is your file being put in the run directory after redeployment?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 03-11-2015, 05:30 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default Re: XC5 Problem overriding class with a module

Hey Mike, thanks for replying.

This is my namespace
Code:
namespace XLite\Module\<Company>\<Module>\View\ItemsList\Product\Customer;
And the file is being put into the run directory after redeployment with the correct contents.

And function code-wise, there shouldn't be a problem there as I can get the code to work temporary by replacing the actual search function in the run directory.
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #4  
Old 03-11-2015, 06:30 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: XC5 Problem overriding class with a module

There is a possibility that another module is also decorating this class, and it may come alphabetically after yours.

In this case you need to make your module depend on the other, and you do this via module dependencies in your main.php I believe.

Check the class that you are decorating in the run directory. It should be extending your class after deployment, or it could be that it is extending another, you can chase through which class depends on which by seeing how they reference each other in the run directory.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
zychen (03-11-2015)
  #5  
Old 03-11-2015, 08:07 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Thumbs up Re: XC5 Problem overriding class with a module

Thanks Mike!

Your answer helped me realize that the bundled CloudSearch Module must have been doing some overriding to the Search class somehow.

Although the class in the run folder didn't specifically point to CloudSearch, my module worked perfectly after disabling CloudSearch

Cheers!
-Niboon
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote

The following 2 users thank zychen for this useful post:
tony_sologubov (03-18-2015), totaltec (03-11-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:05 AM.

   

 
X-Cart forums © 2001-2020