static function reload_courses_to_hikashop($courses) { require_once JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php'; $params = JComponentHelper::getParams('com_joomdle'); $courses_category = $params->get('courses_category'); $db = JFactory::getDBO(); $config = hikashop_config(); foreach ($courses as $sku) { // skip bundles if (strncmp($sku, 'bundle_', 7) == 0) { continue; } $query = "SELECT product_id FROM #__hikashop_product WHERE product_code = " . $db->Quote($sku); $db->setQuery($query); $products = $db->loadObjectList(); if (count($products)) { $product_id = $products[0]->product_id; $element->product_id = $product_id; $course_info = JoomdleHelperContent::getCourseInfo($sku); $name = $course_info['fullname']; $desc = $course_info['summary']; $cost = $course_info['cost']; $currency = $course_info['currency']; $product_class = hikashop_get('class.product'); $element->categories = $product_class->getCategories($product_id); $element->categories[] = $courses_category; $element->related = array(); $element->options = array(); $element->product_name = $name; $element->product_description = $desc; $element->product_code = $sku; $element->product_published = 1; $query = "SELECT category_id FROM #__hikashop_category WHERE category_namekey='default_tax'"; $db->setQuery($query); $tax_id = $db->loadResult(); if ($tax_id) { $element->product_tax_id = $tax_id; $query = "SELECT tax_namekey FROM #__hikashop_taxation WHERE category_namekey='default_tax'"; $db->setQuery($query); $tax_namekey = $db->loadResult(); $query = "SELECT tax_rate FROM #__hikashop_tax WHERE tax_namekey=" . $db->Quote($tax_namekey); $db->setQuery($query); $tax_rate = $db->loadResult(); $div = $tax_rate + 1; $price_without_tax = $cost / $div; $cost = $price_without_tax; } $element->prices = array(); $element->prices[0]->price_value = $cost; $query = "SELECT currency_id FROM #__hikashop_currency WHERE currency_code = '{$currency}'"; $db->setQuery($query); $currency_id = $db->loadResult(); $element->prices[0]->price_currency_id = $currency_id; $element->prices[0]->price_min_quantity = 0; $status = $product_class->save($element); if ($status) { $product_class->updateCategories($element, $status); $product_class->updatePrices($element, $status); } } else { JoomdleHelperShop::sell_courses_on_hikashop(array($sku)); } } }