} $product_record['cat_id'] = $primary_category; } if (is_array($images)) { $primary = 1; foreach ($images as $file_id) { $image_record = array('product_id' => $product_id, 'file_id' => $file_id, 'main_img' => $primary); $GLOBALS['db']->insert('CubeCart_image_index', $image_record); $primary = 0; } } // Insert SEO custom URL if (empty($product_record['seo_path'])) { $product_record['seo_path'] = $GLOBALS['seo']->generatePath($product_id, 'prod'); } $GLOBALS['db']->insert('CubeCart_seo_urls', array('path' => sanitizeSEOPath($product_record['seo_path']), 'item_id' => $product_id, 'type' => 'prod')); } unset($product_record, $category_record, $image_record, $image, $images); } fclose($fp); } unlink($this_import); } $next_cycle = $cycle + 1; if (file_exists(sprintf($import_source, $next_cycle))) { $data = array('next_cycle' => $next_cycle, 'total' => $has_header ? $GLOBALS['session']->get('columns', 'import') - 1 : $GLOBALS['session']->get('columns', 'import'), 'imported' => $cycle * $splitSize); $GLOBALS['smarty']->assign('DATA', $data); $page_content = $GLOBALS['smarty']->fetch('templates/products.importing.php'); } else { $GLOBALS['main']->setACPNotify($lang['catalogue']['notify_import_complete']); $GLOBALS['session']->delete('', 'import');
<?php ## fix any broken SEO paths if ($seo_paths = $db->select('CubeCart_seo_urls', array('id', 'path'))) { foreach ($seo_paths as $seo_path) { $db->update('CubeCart_seo_urls', array('path' => sanitizeSEOPath($seo_path['path'])), array('id' => $seo_path['id'])); } }
/** * Set a DB path * * @param string $type * @param int $item_id * @param string $path * @param bool $bool * @param bool $show_error * @return bool/string */ public function setdbPath($type, $item_id, $path, $bool = true, $show_error = true) { if (in_array($type, array_merge($this->_dynamic_sections, $this->_static_sections))) { $custom = 1; // if path is empty or already taken generate one if (empty($path) || $GLOBALS['db']->count('CubeCart_seo_urls', 'id', "`path` = '{$path}' AND `type` = '{$type}' AND `item_id` <> {$item_id}") > 0) { // send warning if in use if (!empty($path)) { if ($show_error && CC_IN_ADMIN) { $GLOBALS['gui']->setError($GLOBALS['language']->settings['seo_path_taken']); } } // try to generate $path = $this->generatePath($item_id, $type); $custom = 0; } $path = sanitizeSEOPath($path); if (empty($path)) { return $bool ? false : ''; } if (($existing = $GLOBALS['db']->select('CubeCart_seo_urls', 'id', array('type' => $type, 'item_id' => $item_id))) !== false) { $GLOBALS['db']->update('CubeCart_seo_urls', array('type' => $type, 'item_id' => $item_id, 'path' => $path, 'custom' => $custom), array('id' => $existing[0]['id'])); } else { //Check for dup path if (!$GLOBALS['db']->select('CubeCart_seo_urls', false, array('path' => $path))) { $GLOBALS['db']->insert('CubeCart_seo_urls', array('type' => $type, 'item_id' => $item_id, 'path' => $path, 'custom' => $custom)); } else { // Force unique path is it's already taken $unique_id = substr($type, 0, 1) . $item_id; $GLOBALS['db']->insert('CubeCart_seo_urls', array('type' => $type, 'item_id' => $item_id, 'path' => $path . '-' . $unique_id, 'custom' => $custom)); $GLOBALS['gui']->setError($GLOBALS['language']->settings['seo_path_taken']); } } return $bool ? true : $path; } else { trigger_error('Invalid SEO path type ' . $type . '.', E_USER_NOTICE); return false; } }
} $db->update('CubeCart_order_summary', $record, array('cart_order_id' => $order_name['cart_order_id'])); unset($record, $name_parts); } } ## Get SEO paths from seo_custom_url into new SEO DB if ($products = $db->select('CubeCart_inventory', array('product_id', 'seo_custom_url'))) { foreach ($products as $item) { if (empty($item['seo_custom_url'])) { continue; } $db->insert('CubeCart_seo_urls', array('path' => sanitizeSEOPath($item['seo_custom_url']), 'item_id' => $item['product_id'], 'type' => 'prod')); } } if ($categories = $db->select('CubeCart_category', array('cat_id', 'seo_custom_url'))) { foreach ($categories as $item) { if (empty($item['seo_custom_url'])) { continue; } $db->insert('CubeCart_seo_urls', array('path' => sanitizeSEOPath($item['seo_custom_url']), 'item_id' => $item['cat_id'], 'type' => 'cat')); } } ## Sort out taxes if ($tax_rates = $db->select('CubeCart_tax_rates', array('country_id', 'id'))) { foreach ($tax_rates as $tax_rate) { $country = $db->select('CubeCart_geo_country', array('numcode'), array('id' => $tax_rate['country_id'])); if ($country[0]['numcode'] > 0) { $db->update('CubeCart_tax_rates', array('country_id' => $country[0]['numcode']), array('id' => $tax_rate['id'])); } } }