News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[fixed] Search issues

Started by Cleanshooter, October 14, 2011, 16:28:02 PM

Previous topic - Next topic

Cleanshooter

I use SKU numbers for both my product names and product SKU field and when I punch in one of the SKUs in to the search it displays all the products in my catalog. 

It also drops the numbers I typed in the search box.  However when I search for a word like "Pig" it displays nothings (like it should) and keeps the word "Pig" in the search box.

I have my cart in debug mode here are the errors outputted by the system:

Errors

    The database row is empty.
    Information


    Backtrace
    Call stack
    #    Function    Location
    1    JSite->dispatch()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/index.php:43
    2    JComponentHelper::renderComponent()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/includes/application.php:187
    3    require_once()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/libraries/joomla/application/component/helper.php:156
    4    JController->execute()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/components/com_virtuemart/virtuemart.php:62
    5    VirtueMartControllerCategory->Category()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/libraries/joomla/application/component/controller.php:679
    6    VirtuemartViewCategory->display()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/components/com_virtuemart/controllers/category.php:66
    7    VirtueMartModelProduct->getProductsInCategory()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/components/com_virtuemart/views/category/view.html.php:117
    8    VirtueMartModelProduct->getProducts()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/models/product.php:581
    9    VirtueMartModelProduct->getProduct()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/models/product.php:645
    10    VirtueMartModelProduct->getPrice()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/models/product.php:361
    11    calculationHelper->getProductPrices()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/models/product.php:1116
    12    calculationHelper->setCountryState()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/helpers/calculationh.php:244
    13    VirtueMartCart::getCart()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/helpers/calculationh.php:139
    14    VirtueMartCart->setPreferred()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/components/com_virtuemart/helpers/cart.php:140
    15    VirtueMartModelUser->getUser()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/components/com_virtuemart/helpers/cart.php:156
    16    VmTable->load()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/models/user.php:120
    17    JTable->load()    /hermes/bosweb/web139/b1391/ipg.collegekidscom/public_html/joomla_cms/administrator/components/com_virtuemart/helpers/vmtable.php:187

(This output 8 times in debug)

I am going to be working on this all day till I figure it out.  I'll keep you posted if I figure out the problem...

also a bit off topic but when would one go to link up to the svn repository?  Are their instructions with the address in a post somewhere?  Or is svn only for certain members?

-Cleanshooter
- Cleanshooter

Cleanshooter

So now I'm just following the backtrace and I've added some echo statements to the user.php and vmtable.php

echo (int)$this->_id; // user.php line 120
echo $int; //vmtable.php line 186

When I serach for a string there are no errors  and the echo statement output:

0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php

However when I search for a number I get this:

0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
0 - vmtable.php
1 - vmtable.php
2 - vmtable.php
0 - vmtable.php
1 - vmtable.php
43 - user.php
43 - vmtable.php
2 - vmtable.php
3 - vmtable.php
1 - vmtable.php
1 - vmtable.php
3 - vmtable.php
4 - vmtable.php
1 - vmtable.php
1 - vmtable.php
4 - vmtable.php
5 - vmtable.php
1 - vmtable.php
1 - vmtable.php
5 - vmtable.php
6 - vmtable.php
1 - vmtable.php
1 - vmtable.php
826 - vmtable.php
6 - vmtable.php
11 - vmtable.php
1 - vmtable.php
1 - vmtable.php
8 - vmtable.php
- vmtable.php
1 - vmtable.php
1 - vmtable.php
100 - vmtable.php
10 - vmtable.php
12 - vmtable.php
1 - vmtable.php
1 - vmtable.php
11 - vmtable.php
14 - vmtable.php
1 - vmtable.php
1 - vmtable.php
12 - vmtable.php
15 - vmtable.php
1 - vmtable.php
1 - vmtable.php
132 - vmtable.php
126 - vmtable.php
127 - vmtable.php
128 - vmtable.php
139 - vmtable.php
140 - vmtable.php
141 - vmtable.php
142 - vmtable.php
143 - vmtable.php
144 - vmtable.php
145 - vmtable.php
146 - vmtable.php
149 - vmtable.php
150 - vmtable.php
148 - vmtable.php
147 - vmtable.php
135 - vmtable.php
136 - vmtable.php
137 - vmtable.php
134 - vmtable.php
129 - vmtable.php
130 - vmtable.php
131 - vmtable.php
138 - vmtable.php
133 - vmtable.php
79 - vmtable.php
92 - vmtable.php
91 - vmtable.php
84 - vmtable.php
83 - vmtable.php
82 - vmtable.php
81 - vmtable.php
80 - vmtable.php
86 - vmtable.php
85 - vmtable.php
90 - vmtable.php
89 - vmtable.php
88 - vmtable.php
87 - vmtable.php
94 - vmtable.php
93 - vmtable.php
95 - vmtable.php
96 - vmtable.php
97 - vmtable.php
98 - vmtable.php
99 - vmtable.php
110 - vmtable.php
109 - vmtable.php
112 - vmtable.php
117 - vmtable.php
116 - vmtable.php
115 - vmtable.php
114 - vmtable.php
113 - vmtable.php
906 - vmtable.php
123 - vmtable.php
120 - vmtable.php
119 - vmtable.php
118 - vmtable.php
121 - vmtable.php
122 - vmtable.php
124 - vmtable.php
125 - vmtable.php

I'm guessing that the user table doesn't even need to be called during a search now I just need to figure out why it is getting called.

-Cleanshooter
- Cleanshooter

Cleanshooter

#2
Ok I'm getting closer...

It seems that the $keyword variable is getting stripped in the /components/com_virtuemart/views/category/view.html.php:118

If you put in a string it stays but any # gets stripped because JRequest::getWord only allows [A-Za-z_] characters.

I can understand why this was done to prevent injection and all but isn't their a better alternative that will allow number in the search?

Anyway if you change getWord to getString it allows the keyword variable to stick but it still doesn't filter the search results and the same error gets outputted in the debug...

The major change I'm noticing now is in the administrator/components/com_virtuemart/models/product.php:584.   Here is the function with an echo added:

public function getProductsInCategory($categoryId) {

      $ids = $this->sortSearchListQuery();
      foreach($ids as $key => $value) {
            echo $key . " " . $tempID . " - search IDs </br>";
         }
      $this->products = $this->getProducts($ids);
      return $this->products;
   }

When there is a string search "pig" it outputs  0 - search IDs

When you search for any numbers it output the following:
0 - search IDs
1 - search IDs
2 - search IDs
3 - search IDs
4 - search IDs
5 - search IDs
6 - search IDs
7 - search IDs
8 - search IDs
9 - search IDs

Back to the drawing broad

- Cleanshooter
- Cleanshooter

jjk

Quote from: Cleanshooter on October 14, 2011, 16:28:02 PM
... a bit off topic but when would one go to link up to the svn repository?  Are their instructions with the address in a post somewhere?  Or is svn only for certain members?

See here: http://dev.virtuemart.net/projects/virtuemart/wiki/Setting_up_a_Development_Environment
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Milbo

Hello Cleanshooter,
we changed this stuff to getString last week.

Some hints for developing, you may use vmdebug('my message',$var1,$var2); it makes automatically print_r with 1 and pre surrrounding it, so you can just put whole arrays and objects in it. and as many variables as you want (theoretically of course). You must set the right setting in config to see this messages (first tab).

Thanks for the work, hope you get some new results.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Cleanshooter

I just figured it out too  >:(  I replace the getWord with getString in two places and now it works errrr!

Thanks for the link to the SVN  ::)

-Cleanshooter
- Cleanshooter

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/