Post by sagraphics » Wed Mar 14, 2018 1:12 am

Having big problems with trying to create a custom 404 page and htaccess. I created a layout called 'error page' and set the route of that page to error/not_found so I could add modules to improve the look of the page. This didn't override the error page unfortunately so I sought some help. The 'helper' said the issues were more than likely in my htaccess file. He advised that I should add this line:

ErrorDocument 404 index.php?route=error/not_found

But when we do this, the 404 page is a white screen with just "index.php?route=error/not_found" printed on screen...EXCEPT if the product has been disabled rather than deleted - if the product is disabled, it shows the correct customised 404 page.

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by IP_CAM » Wed Mar 14, 2018 3:48 am

Dit you already check on what's freely available on this for OC-2 ?
Ernie
---
Custom vqmod404
https://www.opencart.com/index.php?rout ... n_id=21264
---
Smarter 404
https://www.opencart.com/index.php?rout ... n_id=21506
---

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by sagraphics » Wed Mar 14, 2018 5:06 pm

Looking at these 2 extensions you have mentioned, the first highlights:

" It is for Developers only to further improve it and not for direct users. As it may have some more errors. "

I don't want an extension with errors as I'm working on a live website environment.

The second extension apparently replaces your 404 page with a list of similar products containing a matching keyword. Whilst this is interesting, the extension hasn't been updated in 2 years, and some of the comments states that it simply doesn't work in all cases, including "It looks like a great one but it doesn't work, shows a blank page.."

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by straightlight » Wed Mar 14, 2018 6:31 pm

I don't want an extension with errors as I'm working on a live website environment.
The methodology is flaw. Implementing solutions should never be done on a live website directly but rather having a test environment where the solution can be tested before implementing the solution into the live website.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sagraphics » Thu Mar 15, 2018 8:36 pm

Whilst I understand development shouldn't be done on a live site, I am simply requiring help with my htaccess settings to allow the proper loading of the 404 page for deleted products. It works for disabled products, but we can't keep disabling products as the database will get too big and the backend too messy! You don't need a development environment to add a new layout, and I followed the instructions to the letter about adding new layout to certain pages.

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by straightlight » Thu Mar 15, 2018 8:58 pm

You don't need a development environment to add a new layout, and I followed the instructions to the letter about adding new layout to certain pages.
That theory would be incorrect. Development servers are meant to test features to avoid on corrupting live servers while being in production mode as to avoid server maintenance. The need still applies for those cases so to avoid fallbacks due to misprocesses. Creating a new layout is no different. Testing the layout among other installed features is in fact highly recommended to be done on a dev environment before applying the change to the production environment.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MrPhil » Thu Mar 15, 2018 9:09 pm

Contrary to what some people will tell you, you don't need to install a "local environment" *AMPP server on your PC. You will find it much easier to simply create a test/development private directory on your live server, copy over your current site (or install a new one) and database (don't develop on your live DB), and do your development there. Password protect the test system if you are concerned that someone may get into it. Only if you need to have something (such as a current PHP level) that your host can't provide, should you do a PC installation.

Diagnosing your 404 problem, can you invoke your 404 directly from the browser? If it works, the problem may be your .htaccess. If it doesn't work (such as a blank screen), the problem is likely in the code somewhere. At least confirm that it's one or the other, and eliminate causes.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by straightlight » Thu Mar 15, 2018 9:30 pm

Contrary to what may have been said on the previous, there were nowhere to be said where a local environment was needed.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MrPhil » Thu Mar 15, 2018 9:41 pm

I didn't accuse you (or anyone else in the thread) of suggesting a local system. It's just my experience that sooner or later, someone will chime in with "you have to set up a local system on your PC, to run a development environment". I'm just pointing out in advance that's usually bad advice, as it adds a whole layer of unnecessary complexity to the project.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by sagraphics » Thu Mar 15, 2018 10:36 pm

Okay, so lets overt from arguments, and get back to the issue. Sample of deleted product 404:

https://www.remnanthousefabric.co.uk/cr ... ag-batting

Sample of a disabled product with correct 404:

https://www.remnanthousefabric.co.uk/ja ... collection

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by sagraphics » Mon Mar 19, 2018 8:11 pm

Hi agatha65 - I'm not sure what you mean...I need some help on what's wrong...

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by agatha65 » Wed Mar 21, 2018 6:24 am

Just restore the original not found page - controller and view
Than you can add modules to it creating a layout for it in admin.
If you need help contact me at agatha65@gmail.com

Suppliers Module - XML, CSV, XLS Product Feed Import and Update
Rich Snippets | Facebook Open Graph Meta Tags | WebP Images
Image


User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by sagraphics » Tue Apr 03, 2018 11:13 pm

Hi Agatha, as you can see from my initial post, I tried to do this but it wasn't overriding.

"I created a layout called 'error page' and set the route of that page to error/not_found so I could add modules to improve the look of the page. This didn't override the error page unfortunately so I sought some help. "

My issue is specifically for deleted products - disabled products work just fine.

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by straightlight » Tue Apr 03, 2018 11:54 pm

My issue is specifically for deleted products - disabled products work just fine.
Let's test this theory. In your admin/controller/catalog/product.php file, in the delete() method,

find:

Code: Select all

$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true));
add below:

Code: Select all

echo '<br><br>I can see the step where validateDelete() completes its process!';
			exit;
Then, in your admin/model/catalog/product.php file, in the deleteProduct method,

find:

Code: Select all

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

Code: Select all

echo 'I can see the steps where the products actually gets deleted!';
Save the changes and try to delete a product from the admin noticing the event messages afterwards.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sagraphics » Wed Apr 04, 2018 11:46 pm

I have tried your steps on a test site I've created, and I can't see any additional messages other that "Success: You have modified products".
Before I deleted this product in it's disabled state, the front end of the site would display the correct not found page - first screenshot. After deletion, I refresh this page on the front end, and got my original error - see later screenshot.

Attachments

Screen Shot 2018-04-04 at 16.42.04.png

error - second screenshot - Screen Shot 2018-04-04 at 16.42.04.png (118.46 KiB) Viewed 2923 times

Screen Shot 2018-04-04 at 16.40.26.png

first screen shot - Screen Shot 2018-04-04 at 16.40.26.png (1.32 MiB) Viewed 2923 times


New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by straightlight » Wed Apr 04, 2018 11:56 pm

I have tried your steps on a test site I've created, and I can't see any additional messages other that "Success: You have modified products".
That was the point of my modifications above and as indicated, it would show you two other messages. Were you able to see those messages?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sagraphics » Thu Apr 05, 2018 4:24 pm

No, i did not see any other messages.

In the first file, modified to:

public function delete() {
$this->load->language('catalog/product');

$this->document->setTitle($this->language->get('heading_title'));

$this->load->model('catalog/product');

if (isset($this->request->post['selected']) && $this->validateDelete()) {
foreach ($this->request->post['selected'] as $product_id) {
$this->model_catalog_product->deleteProduct($product_id);
}

$this->session->data['success'] = $this->language->get('text_success');

$url = '';

if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_price'])) {
$url .= '&filter_price=' . $this->request->get['filter_price'];
}

if (isset($this->request->get['filter_quantity'])) {
$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}

if (isset($this->request->get['filter_status'])) {
$url .= '&filter_status=' . $this->request->get['filter_status'];
}

if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}

if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}

if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}

$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
echo '<br><br>I can see the step where validateDelete() completes its process!';
exit;
}

In the second file modified to:

public function deleteProduct($product_id) {
$this->event->trigger('pre.admin.product.delete', $product_id);

$this->db->query("DELETE FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_recurring WHERE product_id = " . (int)$product_id);
$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id . "'");

$this->cache->delete('product');
echo 'I can see the steps where the products actually gets deleted!';

$this->db->query("DELETE FROM " . DB_PREFIX . "product_accessory WHERE product_id = '" . (int)$product_id . "'");

$this->event->trigger('post.admin.product.delete', $product_id);
}

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am

Post by sagraphics » Fri Apr 20, 2018 6:12 pm

Any further help would be appreciated...

New member

Posts

Joined
Sat Nov 11, 2017 3:41 am
Who is online

Users browsing this forum: No registered users and 22 guests