Post by rh001 » Sun Jun 30, 2024 3:32 pm

Hi! I have augmented Search to include blog posts. But there is a glitch: If search keyword does not return 1 or more products then it will not return any blog posts even if there is a blog post(s) with the keyword. It's like the code is saying "no matching products so quit". I think this is happening in the file:

catalog/controller/product/search.php

added code:
Line 23
// Load the Journal2 Blog Model
$this->load->model('journal2/blog');
$data['blog_posts'] = array(); // Initialize the blog_posts array

Line 988
// Fetch blog posts based on the search term
$blog_results = $this->model_journal2_blog->getBlogPostsByKeyword($search);

foreach ($blog_results as &$blog_post) {
// Check if 'journal_blog_post_id' is set to avoid undefined index notice
if (isset($blog_post['post_id'])) {
$blog_post['href'] = $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $blog_post['post_id']);
} else {
// Handle the case where 'journal_blog_post_id' is not set, if necessary
$blog_post['href'] = '#'; // or some default value
}
}

// Pass blog results to the view
$data['blog_results'] = $blog_results;


A couple other files have been modded to get this augmentation but I don't think the problem is with them.

OC 2.3.0.2 and Journal2 theme

Any ideas will be appreciated.
Last edited by rh001 on Wed Jul 03, 2024 12:17 am, edited 1 time in total.

New member

Posts

Joined
Sun Dec 06, 2015 7:21 am

Post by JNeuhoff » Sun Jun 30, 2024 5:20 pm

OpenCart 2 does not include a blog feature. The Journal2 framework is not the same as OpenCart, hence you have to contact the Journal support, or find a professional developer from the commercial support section to do the needed changes for the search.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by rh001 » Sun Jun 30, 2024 10:28 pm

Hi and thank for the reply.

My question is about the Opencart search function and is general, not about Journal2 theme specifically. I posted here just to ask and don't appreciate the effort you took to scold me. You're a scold. Any future harrassment from you will be reported.

New member

Posts

Joined
Sun Dec 06, 2015 7:21 am

Post by halfhope » Mon Jul 01, 2024 10:34 am

Hi!

Try to look at template file. It can have something like this:

Code: Select all

{% if products %}
I think your code in template file for output founded posts is in this block. Try to move it down.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by rh001 » Tue Jul 02, 2024 1:56 am

To HalfHope:

Bingo! Good call. See pics.

Thanks, Rob

Attachments

Journal2 blog names added to main Search.JPG

Journal2 blog names added to main Search.JPG (137.59 KiB) Viewed 911 times

Journal2 blog names added to main Search(2).JPG

Journal2 blog names added to main Search(2).JPG (148.49 KiB) Viewed 911 times


New member

Posts

Joined
Sun Dec 06, 2015 7:21 am

Post by paulfeakins » Tue Jul 02, 2024 6:58 pm

rh001 wrote:
Tue Jul 02, 2024 1:56 am
Bingo! Good call.
If that solves the issue please add [SOLVED] to the start of this topic title.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by halfhope » Tue Jul 02, 2024 10:20 pm

rh001 wrote:
Tue Jul 02, 2024 1:56 am
To HalfHope:

Bingo! Good call. See pics.

Thanks, Rob
You're welcome. Happy to help.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego
Who is online

Users browsing this forum: No registered users and 13 guests