Post by letxobnav » Tue Apr 07, 2020 11:07 am

you are using PHP version lower than 7.0.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member
Online

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Tue Apr 07, 2020 11:50 am

for php lower than 7 try this version

You add 2 defines in root config.php

Code: Select all

// SEO
// cache seo keywords in constant by one query in startup
define('USE_SEO_CACHE', true);
// additionally, store the seo keywords cache in file (might actually slow things down, reading cache file vs query)
define('USE_SEO_CACHE_FILE', false);
in catalog/controller/startup/startup.php after:

Code: Select all

		// OpenBay Pro
		$this->registry->set('openbay', new Openbay($this->registry));
you add:

Code: Select all

		// SEO CACHE if seo urls enabled and seo cache enabled
		if ($this->config->get('config_seo_url') && USE_SEO_CACHE) {
			$pairs = false;
			// define cache storage by store and language
			$seo_pair_cache_file = 'seo.'.$this->config->get('config_store_id').'.'.$this->config->get('config_language_id');
			// read cache storage if enabled
			if (USE_SEO_CACHE_FILE) $pairs = $this->cache->get($seo_pair_cache_file);
			// if no storage or no storage enabled fetch all seo query/keyword pairs for store and language
			if (!$pairs) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "' order by keyword ASC ");
				$pairs = array();
				// build query/keyword pairs
				foreach ($query->rows as $row) $pairs[$row['query']] = $row['keyword'];
				// store the pairs in file if enabled
				if (USE_SEO_CACHE_FILE) $this->cache->set($seo_pair_cache_file, $pairs);
				// free memory
				unset ($query);
			}
			// define the pair constant
			global $seo_pairs;
			$seo_pairs = $pairs;
			// free memory
			unset($pairs);
		}
if catalog/controller/startup/seo_url.php after:

Code: Select all

	public function rewrite($link) {
add:

Code: Select all

global $seo_pairs;
You replace this part:

Code: Select all

		foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

					if ($query->num_rows && $query->row['keyword']) {
						$url .= '/' . $query->row['keyword'];

						unset($data[$key]);
					}
				} elseif ($key == 'path') {
					$categories = explode('_', $value);

					foreach ($categories as $category) {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

						if ($query->num_rows && $query->row['keyword']) {
							$url .= '/' . $query->row['keyword'];
						} else {
							$url = '';

							break;
						}
					}

					unset($data[$key]);
				}
			}
		}
with this:

Code: Select all

		foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
					if (USE_SEO_CACHE && $seo_pairs) {
						if (isset($seo_pairs[$key . '=' . $value])) {
							$url .= '/' . $seo_pairs[$key . '=' . $value];
							unset($data[$key]);
						}
					} else {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
						if ($query->num_rows && $query->row['keyword']) {
							$url .= '/' . $query->row['keyword'];
							unset($data[$key]);
						}
					}
				} elseif ($key == 'path') {
					$categories = explode('_', $value);
					foreach ($categories as $category) {
						if (USE_SEO_CACHE && $seo_pairs) {
							if (isset($seo_pairs['category_id=' . $category])) {
								$url .= '/' . $seo_pairs['category_id=' . $category];
								unset($data[$key]);
							} else {
								$url = '';
								break;
							}
						} else {
							$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
							if ($query->num_rows && $query->row['keyword']) {
								$url .= '/' . $query->row['keyword'];
							} else {
								$url = '';
								break;
							}
						}
					}
					unset($data[$key]);
				}
			}
		}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member
Online

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Tue Apr 07, 2020 2:24 pm

if you set the file cache to true:

Code: Select all

define('USE_SEO_CACHE_FILE', true);
better add the command to delete the seo file cache after editing seo urls in the models for product, category, information and manufacturer

for example:
admin/model/catalog/product.php

after:

Code: Select all

$this->cache->delete('product');
add:

Code: Select all

$this->cache->delete('seo');
but frankly, using the file cache only eliminates one query so I never use it.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member
Online

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by moshair » Wed Apr 08, 2020 2:05 am

Thank you letxobnav, it works very good. I used the PHP 7 version in the website.

The problem happened again even with disabling SEO URL and category count and before usingt seo cache, I will see tomorrow what will happen.
It seems I should move to another host. I asked byet.host about max_questions limit on there plans and what is the best plan according to my site traffic, they replied :
Please see below the details :

Super premium CPU units: 200 CPU cores: 2 - RAM: 1024 MB Concurrent processes (EP) :22 - i/o (kbps) 6096
Ultimate premium CPU units: 800 CPU cores: 3 - RAM: 1024 MB Concurrent processes (EP) :25 - i/o (kbps) 6096
Business Hosting Standard CPU units: 800 CPU cores: 3 - RAM: 1024 MB Concurrent processes (EP) :35 - i/o (kbps) 10000

The VPS servers are measured differently and cant be compared, based on your traffic our ultimate plan should be perfect for your site I see no reason why it would not run great at iFastNet.
They didn't mention the max_questions value for each plan. Do you think I should know the max_questions value before moving to that host or things will be fine, I didn't understand all plan details like (EP) :25 - i/o (kbps) 6096?

Regards,

Newbie

Posts

Joined
Sun Jul 21, 2019 3:27 pm

Post by letxobnav » Wed Apr 08, 2020 11:38 am

well, I am sure they believe that their "Ultimate plan" is a perfect fit.
I am not sure about what hosting to use, I don't use hosting so I have no limits, just the physical ones.

The CPU and I/O numbers are meaningless to the average user who has no way of knowing what is required there to make their eCommerce site perform.
The real important items are the commercial policies they set themselves like database max connections and/or questions aside from their support quality of course.

max_questions means the limit they set on the number of queries a user can execute within a specific timeframe so I would demand an answer on that.
If they cannot answer that, move on.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member
Online

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: paulfeakins and 27 guests