updatescript doofinder
This commit is contained in:
parent
adcebf60ef
commit
bb5cc57f75
@ -6,7 +6,7 @@ require_once(dirname(__FILE__) . '/../../cmsps/classes/CmsPsCategory.php');
|
||||
|
||||
|
||||
if (Tools::getValue('token', null) != 'QlUdloxwKgQSD2lRkSxDhT4ky') {
|
||||
die('Forbidden');
|
||||
die('Forbidden');
|
||||
}
|
||||
|
||||
$db = Db::getInstance();
|
||||
@ -20,84 +20,95 @@ $delimiter = '|';
|
||||
$file = fopen($filename, 'w+');
|
||||
//fprintf($file, chr(0xEF).chr(0xBB).chr(0xBF));
|
||||
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'cmsps_posts_lang';
|
||||
$datas = $db->ExecuteS($sql);
|
||||
$datas = $db->ExecuteS('
|
||||
SELECT cp.`id_post`, cpl.`meta_desc`, cpl.`title`
|
||||
FROM `'._DB_PREFIX_.'cmsps_posts` cp
|
||||
INNER JOIN `'._DB_PREFIX_.'cmsps_posts_lang` cpl ON (cp.`id_post` = cpl.`id_post`)
|
||||
WHERE cpl.`id_lang` = 1
|
||||
AND cp.`active` = 1
|
||||
');
|
||||
|
||||
$link = new Link();
|
||||
|
||||
foreach ($datas as $key => $data) {
|
||||
$p = new CmsPsPost($data['id_post']);
|
||||
$default_category = new CmsPsCategory(getRootCategoryCms($p->id_category));
|
||||
$lines[] = array(
|
||||
$data['title'],
|
||||
$link->getPostCmsLink($data['id_post']),
|
||||
str_replace("\r", '', str_replace("\n", '', $data['meta_desc'])),
|
||||
$data['id_post'],
|
||||
0,
|
||||
$p = new CmsPsPost($data['id_post']);
|
||||
$id_post = '100'. $data['id_post'];
|
||||
$default_category = new CmsPsCategory(getRootCategoryCms($p->id_category));
|
||||
$lines[] = array(
|
||||
$data['title'],
|
||||
$link->getPostCmsLink($data['id_post']),
|
||||
str_replace("\r", '', str_replace("\n", '', $data['meta_desc'])),
|
||||
(int) $id_post,
|
||||
0,
|
||||
_PS_BASE_URL_.'/img/cms_post/'.$data['id_post'].'/small.jpg',
|
||||
'',
|
||||
$default_category->title[1],
|
||||
'article',
|
||||
0,
|
||||
_PS_BASE_URL_.'/img/cms_post/'.$data['id_post'].'/small.jpg',
|
||||
'',
|
||||
$default_category->title[1],
|
||||
'article',
|
||||
''
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'product_lang';
|
||||
$datas = $db->ExecuteS($sql);
|
||||
|
||||
$datas = $db->ExecuteS('
|
||||
SELECT p.`id_product`, pl.`name`, pl.`description`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||
WHERE pl.`id_lang` = 1
|
||||
AND p.`active` = 1
|
||||
');
|
||||
foreach ($datas as $key => $data) {
|
||||
$p = new Product((int)$data['id_product']);
|
||||
$sql = 'SELECT fvl.value FROM '._DB_PREFIX_.'feature_value_lang fvl
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_feature_value = fvl.id_feature_value AND fvl.id_lang = 1)
|
||||
WHERE fp.id_product = '.(int)$data['id_product'].' AND fp.id_feature = 8';
|
||||
$p = new Product((int)$data['id_product']);
|
||||
$sql = '
|
||||
SELECT fvl.`value`
|
||||
FROM `'._DB_PREFIX_.'feature_value_lang` fvl
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_feature_value` = fvl.`id_feature_value` AND fvl.id_lang = 1)
|
||||
WHERE fp.id_product = '.(int) $data['id_product'].'
|
||||
AND fp.id_feature = 8';
|
||||
|
||||
$feature = Db::getInstance()->getValue($sql);
|
||||
|
||||
$cover = Product::getCover((int)$data['id_product'])['id_image'];
|
||||
$default_category = new Category(getRootCategoryProduct($p->getDefaultCategory()));
|
||||
$lines[] = array(
|
||||
$data['name'],
|
||||
$link->getProductLink(new Product($data['id_product'])),
|
||||
str_replace("\r", '', str_replace("\n", '', $data['description'])),
|
||||
$data['id_product'],
|
||||
$cover = Product::getCover((int)$data['id_product'])['id_image'];
|
||||
$id_product = '200'. $data['id_product'];
|
||||
$default_category = new Category(getRootCategoryProduct($p->getDefaultCategory()));
|
||||
$lines[] = array(
|
||||
$data['name'],
|
||||
$link->getProductLink(new Product($data['id_product'])),
|
||||
str_replace("\r", '', str_replace("\n", '', $data['description'])),
|
||||
(int) $id_product,
|
||||
$p->getPrice(true, null, 2, null, false, false),
|
||||
$p->getPrice(),
|
||||
$link->getImageLink($p->link_rewrite[1], $cover),
|
||||
$default_category->name[1],
|
||||
'',
|
||||
'product',
|
||||
$default_category->name[1],
|
||||
'',
|
||||
'product',
|
||||
$feature
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
foreach ($lines as $key => $line) {
|
||||
fputcsv($file, $line, $delimiter);
|
||||
fputcsv($file, $line, $delimiter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function getRootCategoryProduct($id_category)
|
||||
{
|
||||
$sql = 'SELECT id_parent FROM '._DB_PREFIX_.'category WHERE id_category = '.(int)$id_category;
|
||||
$id_parent = Db::getInstance()->getValue($sql);
|
||||
if (in_array($id_parent, array(1, 2, 0))) {
|
||||
return $id_category;
|
||||
}
|
||||
return getRootCategoryProduct($id_parent);
|
||||
$sql = 'SELECT `id_parent` FROM `'._DB_PREFIX_.'category` WHERE `id_category` = '.(int)$id_category;
|
||||
$id_parent = Db::getInstance()->getValue($sql);
|
||||
if (in_array($id_parent, array(1, 2, 0))) {
|
||||
return $id_category;
|
||||
}
|
||||
return getRootCategoryProduct($id_parent);
|
||||
}
|
||||
|
||||
function getRootCategoryCms($id_category)
|
||||
{
|
||||
$sql = 'SELECT id_parent FROM '._DB_PREFIX_.'cmsps_categories WHERE id_category = '.(int)$id_category;
|
||||
$id_parent = Db::getInstance()->getValue($sql);
|
||||
if ($id_parent == 0) {
|
||||
return $id_category;
|
||||
} else {
|
||||
return getRootCategoryProduct($id_parent);
|
||||
}
|
||||
$sql = 'SELECT `id_parent` FROM `'._DB_PREFIX_.'cmsps_categories` WHERE `id_category` = '.(int)$id_category;
|
||||
$id_parent = Db::getInstance()->getValue($sql);
|
||||
if ($id_parent == 0) {
|
||||
return $id_category;
|
||||
} else {
|
||||
return getRootCategoryProduct($id_parent);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user