X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   Smart Search and PHP7 (https://forum.x-cart.com/showthread.php?t=74902)

susilosaja 01-24-2017 02:13 AM

Smart Search and PHP7
 
Has anyone tried making the latest unencrypted version of Smart Search to work on PHP7? I just upgraded to PHP7, and found some errors with it.

On the front-end, the ajax predictive search show some errors regarding the use of some deprecated functions, the mysql_ functions and preg_replace. Managed to fix these.

On the back-end, opening Tools - Smart Search just show a blank page.

BCSE 01-24-2017 11:13 AM

Re: Smart Search and PHP7
 
We could help you if you'd like to drop us an email. We would need access to the apache error log file to see what is wrong so we can better quote.

http://www.bcsengineering.com/free_quote/

thanks!

Carrie

cflsystems 01-24-2017 06:06 PM

Re: Smart Search and PHP7
 
we can get this fixed for you. Just open a ticket at https://www.cflsystems.com/support/

mattstyle2 02-05-2017 09:12 PM

Re: Smart Search and PHP7
 
I got alterdcart onepage checkout to work with php 7 and xc4.7.7

remove:
PHP Code:

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }



from modules/cdseolinks/cdseo_config.php if you have that installed.. if not just add the code below to init.php

and move it to
/init.php after
PHP Code:

func_set_time_limit(SECONDS_PER_MIN 5); 


and add a mysql_insert_id function so it looks like this

PHP Code:

// smarty3 needs a lot of time to compile all templates_c from scratch
func_set_time_limit(SECONDS_PER_MIN 5);

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }
    function 
mysql_insert_id ()
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_insert_id($link->getLink());
    }
    
}

/**
 * Allow displaying content in functions, registered in register_shutdown_function()
 */
$zlib_oc ini_get('zlib.output_compression'); 


This will bring back the old mysql functions :)


then mod /modules/Checkout_One/JSON.php (not sure this is required but I had to do it for hhvm to work).

PHP Code:

function encodeUnsafe($var)
    {
        
// see bug #16908 - regarding numeric locale printing
       // $lc = setlocale(LC_NUMERIC, 0);
       // setlocale(LC_NUMERIC, 'C');
        
$ret $this->_encode($var);
        
//setlocale(LC_NUMERIC, $lc);
        
return json_encode($var);
        
//        return $ret;
        
    


change that function to use json_encode

finally change a template file:
/skin/common_files/modules/Checkout_One/checkout_one_payment_methods.tpl
line 29:
PHP Code:

{foreach from=$payment_methods item=v}
                        <
tbody{* matt remvoe if $v.membershipids || $v.is_cod == 'Y'style="display:none;"{/if*} id="radio_trcell_{$v.paymentid}">
                            <
tr class="{cycle values='rowA,rowB'}"


just comment out the code to make things display:none.. The radio buttons for payment were not available.

seems to work.. I did a test order with a bad cc # and it declined it.. Using BSCE's authorize.net's DPM mod.. Still nned to figure out a way to subscribe mail chimp users still.. I'll update this as I work on it.

also, there's a few @mysql_query functions in the Checkout_One code you need to change to @db_query

find those..
cd modules/Checkout_One
grep -r --include="*.php" "@mysql_query"

find all instances and change to "@db_query"
there's not that many.





-Matt

xim 02-05-2017 10:20 PM

Re: Smart Search and PHP7
 
Check this cloud service: https://market.x-cart.com/addons/cloudsearch.html

It provides more functionality than SmartSearch

susilosaja 02-07-2017 08:12 PM

Re: Smart Search and PHP7
 
Thanks for both the offers regarding Smart Search. I managed to fix it. Tools - Smart Search on the backend showed a blank page because it still uses the deprecated mysql_query function. It didn't show the error because there was this error suppresing operator '@' in front of those functions. The fix is just basically replacing all mysql_query function with xcart's db functions.

susilosaja 02-07-2017 08:25 PM

Re: Smart Search and PHP7
 
Quote:

Originally Posted by xim
Check this cloud service: https://market.x-cart.com/addons/cloudsearch.html

It provides more functionality than SmartSearch


The drawback I find with Cloud Search is that it couldn't search on custom fields, which I do need. And the pricing. Other than that it seems like good stuff.

mattstyle2 02-07-2017 08:41 PM

Re: Smart Search and PHP7
 
Quote:

Originally Posted by susilosaja
The drawback I find with Cloud Search is that it couldn't search on custom fields, which I do need. And the pricing. Other than that it seems like good stuff.



you can modify modules/Cloud_Search/func.php

to make it search custom fields!
just mod the query
func_query("
SELECT p.product AS name,
p.productcode AS sku,
p.descr AS description,
p.fulldescr AS fullDescription,
p.productid AS id,
p.keywords AS keywords,

then append to description:
$products[$k]['description'].=" ".$p['keywords'];

--- how bout that?!

CS is pretty cheap compared to other search providers such as SLI search.

-Matt

susilosaja 02-07-2017 11:44 PM

Re: Smart Search and PHP7
 
Quote:

Originally Posted by mattstyle2
you can modify modules/Cloud_Search/func.php

to make it search custom fields!
just mod the query
func_query("
SELECT p.product AS name,
p.productcode AS sku,
p.descr AS description,
p.fulldescr AS fullDescription,
p.productid AS id,
p.keywords AS keywords,

then append to description:
$products[$k]['description'].=" ".$p['keywords'];

--- how bout that?!

CS is pretty cheap compared to other search providers such as SLI search.

-Matt


Thanks! I might look into this again later.

Pop Electronics 02-21-2017 06:38 AM

Re: Smart Search and PHP7
 
Quote:

Originally Posted by mattstyle2
I got alterdcart onepage checkout to work with php 7 and xc4.7.7

remove:
PHP Code:

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }



from modules/cdseolinks/cdseo_config.php if you have that installed.. if not just add the code below to init.php

and move it to
/init.php after
PHP Code:

func_set_time_limit(SECONDS_PER_MIN 5); 


and add a mysql_insert_id function so it looks like this

PHP Code:

// smarty3 needs a lot of time to compile all templates_c from scratch
func_set_time_limit(SECONDS_PER_MIN 5);

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }
    function 
mysql_insert_id ()
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_insert_id($link->getLink());
    }
    
}

/**
 * Allow displaying content in functions, registered in register_shutdown_function()
 */
$zlib_oc ini_get('zlib.output_compression'); 


This will bring back the old mysql functions :)


then mod /modules/Checkout_One/JSON.php (not sure this is required but I had to do it for hhvm to work).

PHP Code:

function encodeUnsafe($var)
    {
        
// see bug #16908 - regarding numeric locale printing
       // $lc = setlocale(LC_NUMERIC, 0);
       // setlocale(LC_NUMERIC, 'C');
        
$ret $this->_encode($var);
        
//setlocale(LC_NUMERIC, $lc);
        
return json_encode($var);
        
//        return $ret;
        
    


change that function to use json_encode

finally change a template file:
/skin/common_files/modules/Checkout_One/checkout_one_payment_methods.tpl
line 29:
PHP Code:

{foreach from=$payment_methods item=v}
                        <
tbody{* matt remvoe if $v.membershipids || $v.is_cod == 'Y'style="display:none;"{/if*} id="radio_trcell_{$v.paymentid}">
                            <
tr class="{cycle values='rowA,rowB'}"


just comment out the code to make things display:none.. The radio buttons for payment were not available.

seems to work.. I did a test order with a bad cc # and it declined it.. Using BSCE's authorize.net's DPM mod.. Still nned to figure out a way to subscribe mail chimp users still.. I'll update this as I work on it.

also, there's a few @mysql_query functions in the Checkout_One code you need to change to @db_query

find those..
cd modules/Checkout_One
grep -r --include="*.php" "@mysql_query"

find all instances and change to "@db_query"
there's not that many.





-Matt


Thanks, whis also works when still on php 5.6 but upgrading to X-Cart 4.7.7, I did not have to change mysql_query though for just 4.7.7 on php 5.5.


All times are GMT -8. The time now is 02:29 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.