| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Extending Tags Module without Breaking Search | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Extending Tags Module without Breaking Search
I've created a module that extends the Tags module. Basically it does site-wide filtering on grouped tags.
The problem is the code below is breaking the search - I guess as I'm decorating a class that search uses. How can I use my querybuilder code below without breaking search? PHP Code:
__________________
Core version: 5.5.xx |
|||||||
#2
|
|||||||
|
|||||||
Re: Extending Tags Module without Breaking Search
OK.. I've done it like this....
PHP Code:
The problem now is that getItemsCount() is counting all the products in the store while the page (the Itemlist) shows the correct result. I don't know why getData() finds the products based on the tags correctly but it doesn't count the number of results.
__________________
Core version: 5.5.xx |
|||||||
#3
|
|||||||||
|
|||||||||
Re: Extending Tags Module without Breaking Search
Hi @xgarb,
You do not need to change prepareCndSubstring() method in this case at all. You should define a new condition in your ItemsList, e.g. TagsSubstring and then add the handler of this condition to \XLite\Model\Repo\Product class. See more about conditions here: https://devs.x-cart.com/getting_started/working-with-database.html#method-search See example of adding such condition to ItemsList here: https://devs.x-cart.com/basics/itemslist_in_admin_area/ see how we define getSearchCondition() method there. Please, let me know if it makes sense to you. If it is unclear what I am trying to explain, please let me know. I will be happy to help. Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#4
|
|||||||
|
|||||||
Re: Extending Tags Module without Breaking Search
Thanks for the tips. This is what I have so far...
Controller PHP Code:
Repo PHP Code:
Tag Model PHP Code:
Tag Group Model PHP Code:
ItemsList PHP Code:
I have the following error: [Semantical Error] line 0, col 314 near 'tt WHERE p.enabled': Error: 'tt' is already defined. from this code PHP Code:
in this file: XLite\Module\XC\ProductTags\Model\Repo\Product I'm not sure what to do to stop the querybuilder adding the code in ProductTags repo? T
__________________
Core version: 5.5.xx |
|||||||
#5
|
|||||||||
|
|||||||||
Re: Extending Tags Module without Breaking Search
Hi @xgarb,
Perfect, seems like the mod is almost complete! I do not think you need this 'moreThan10' condition though. This error seems to be caused by a bug. The addTranslationJoins() method should have used linkLeft() method instead of leftJoin() one. I will report that. As a workaround solution, try to add the following method to your \XLite\Module\XCExample\SearchRepoDemo\Model\Repo\ Product class PHP Code:
Please, let me know if it fixes the problem. Tony Quote:
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#6
|
|||||||
|
|||||||
Re: Extending Tags Module without Breaking Search
That change gives me a 500 error with Allowed memory size of 268435456 bytes exhausted in the log.
I think it's something to do with this in my Product Repo.. $this->addTranslationJoins($result, 't', 'tt', $this->getTranslationCode()); and the same code in the prepareCndSubstring() method of the X-cart Tags module. Due to both extending \XLite\Model\Repo\Product maybe.
__________________
Core version: 5.5.xx |
|||||||
#7
|
|||||||||
|
|||||||||
Re: Extending Tags Module without Breaking Search
Hi @xgarb,
I tried the same solution on my X-Cart and it worked out properly. However, this error might be caused by the fact that MySQL query is too heavy and Doctrine cannot handle it properly on your server. When you received this Allowed memory size of 268435456 bytes exhausted error, were there any hints about what might be causing it? Maybe some backtrace? Tony Quote:
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#8
|
|||||||
|
|||||||
Re: Extending Tags Module without Breaking Search
This is the X-cart PHP log...
Code:
So not much help. The query was working when I was just over-riding the prepareCndSubstring but I didn't get the correct count value and as you've shown it's not really the right way to do this. I could add some logging into the prepareCndSubstring() method of the X-cart Tags module to see what it's doing?
__________________
Core version: 5.5.xx |
|||||||
#9
|
|||||||
|
|||||||
Re: Extending Tags Module without Breaking Search
'K I have it nearly working again. The problem with the memory error turned out to be a problem with a duplicate file with a lowercase letter (Linux server, Windows workstation )
I've also solved the problem with the Error: 'tt' is already defined error with this code PHP Code:
So the only problem is the items count is counting all products and not just the ones returned. Using this prepared statement works fine. The items count is correct. PHP Code:
This prepared statement returns the correct items but the item count is wrong PHP Code:
Is there some code in the statement that prevents the count function working?
__________________
Core version: 5.5.xx |
|||||||
#10
|
|||||||||
|
|||||||||
Re: Extending Tags Module without Breaking Search
Hi @xgarb,
Quote:
I do not see any problem with the code you have shown (assuming that your ItemsList class has proper getSearchCondition() method). Moreover, I tried to replicate similar module locally and it works well: no errors with counting. You should probably dig into \XLite\View\ItemsList\AItemsList::getItemsCount() method to find out the real reason of this problem. Surely, before that you should disable widget's cache (Look & feel > Performance section in admin area). Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
|||
X-Cart forums © 2001-2020
|