1. SP LMS
  2. Tuesday, 18 August 2020
In related courses i discovered that the results are based on the course name.

This is a major issue as if there are no other courses with similar name then, the same course is listed under similar courses. & in second scenario non related courses are also shown if just the course name is matching somehow, although one course is of be cooking category & other of engineering category.
This is not logical

Similar courses/related courses should list other courses from the same category.

I zeroed down to the components\com_splms\models\courses.php
->public function getRelatedCourses


public function getRelatedCourses($course_name, $course_id, $cat_id, $limit = 3) {
$search = preg_replace('#\xE3\x80\x80#s', " ", htmlspecialchars(trim($course_name)));
$search_array = explode(" ", $search);

$str_tag_ids = implode(' OR ', array_map(function ($entry) {
return "a.title LIKE '%" . $entry . "%'";
}, $search_array));
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select( array('a.id', 'a.title', 'a.alias', 'a.level', 'a.course_sub_title', 'a.course_time', 'a.image', 'a.price', 'a.sale_price') );
$query->select($db->quoteName('b.title', 'category_name'));
$query->from($db->quoteName('#__splms_courses', 'a'));
$query->join('LEFT', $db->quoteName('#__splms_coursescategories', 'b') . ' ON (' . $db->quoteName('a.coursecategory_id') . ' = ' . $db->quoteName('b.id') . ')');
$query->where($db->quoteName('a.id')." != ".$db->quote($course_id));
$query->where($db->quoteName('a.published')." = ".$db->quote('1'));

if ($str_tag_ids) {
$query->where($str_tag_ids);
}

$query->setLimit($limit);
$db->setQuery($query);
$relatedCourses = $db->loadObjectList();

foreach ($relatedCourses as &$relatedCourse) {
$relatedCourse->thumbnail = SplmsHelper::getThumbnail($relatedCourse->image);
$relatedCourse->url = JRoute::_('index.php?option=com_splms&view=course&id=' . $relatedCourse->id . ':' . $relatedCourse->alias . SplmsHelper::getItemId('courses'));
}

return $relatedCourses;
}


Can you please help me to simplify this function so that it only returns courses from same category.

regards
Responses (2)
Thanks Toufiq,
I almost forgot that i had this issue ;)
Will implement & check it out. once again thanks!
regards
  1. more than a month ago
  2. SP LMS
  3. # 1
Hi there,

Thanks for contacting us. Please follow the process.

Download the zip file (courses.php) & replace this file on this location
components/com_splms/models/courses.php

-Thanks
Attachments (1)
  1. more than a month ago
  2. SP LMS
  3. # 2


There are no replies made for this post yet.
Be one of the first to reply to this post!


This forum is archived

This forum has been archived. Please use JoomShaper official support system.