static function reload_courses_to_tienda($courses) { require_once JPATH_ADMINISTRATOR . '/' . 'components' . '/' . 'com_tienda' . '/' . 'defines.php'; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/' . 'components' . '/' . 'com_tienda' . '/' . 'tables'); $params = JComponentHelper::getParams('com_joomdle'); $courses_category = $params->get('courses_category'); $db = JFactory::getDBO(); foreach ($courses as $sku) { // skip bundles if (strncmp($sku, 'bundle_', 7) == 0) { continue; } $query = "SELECT product_id FROM #__tienda_products WHERE product_sku = " . $db->Quote($sku); $db->setQuery($query); $products = $db->loadObjectList(); if (count($products)) { $product_id = $products[0]->product_id; $course_info = JoomdleHelperContent::getCourseInfo($sku); $name = $course_info['fullname']; $desc = $course_info['summary']; $cost = $course_info['cost']; $currency = $course_info['currency']; $product = JTable::getInstance('Products', 'TiendaTable'); $product->load($product_id); $product->product_name = $name; $product->product_description = $desc; $product->product_description_short = $desc; $product->product_sku = $sku; $product->product_enabled = 1; $product->product_check_inventory = 0; // XXX Esto no va en joomdle.info... differente version? $product->product_ships = 0; $product->save(); /* Set price */ $price = JTable::getInstance('ProductPrices', 'TiendaTable'); $price->load(array('product_id' => $product_id)); $price->product_id = $product->product_id; $price->product_price = $cost; $price->group_id = 1; $price->save(); /* Set category */ $category = JTable::getInstance('Productcategories', 'TiendaTable'); $category->product_id = $product->id; $category->category_id = $courses_category; if (!$category->save()) { $this->messagetype = 'notice'; $this->message .= " :: " . $category->getError(); } } else { JoomdleHelperShop::sell_courses_on_tienda(array($sku)); } } }