Jump to content

Recommended Posts

Помогите подкорректировать код в XML файле на симпле. Мне его написали для портала Аукро. На портале подтягиваются товары и вместо полного описания подтягивается краткое описание товара. Спросил у Аукро, откуда они описание берут - сказали с тега <description/> </description>

Я в коде нашёл только одно место, где есть слово description. 

 

print "\t<description>".htmlspecialchars(strip_tags($p->annotation))."</description>

 

Подскажите, как изменить код, чтобы полное описание подтягивалось.

Link to post
Share on other sites

Что-то описание всё таки не подтягивается. Может где-то ещё можно подправить?

 

<?php
 
require_once('api/Simpla.php');
$simpla = new Simpla();
 
header("Content-type: text/xml; charset=UTF-8");
// Заголовок
print
"<?xml version='1.0' encoding='UTF-8'?>
<price date='".date('Y-m-d H:m')."'>
<name>".$simpla->settings->site_name."</name> 
";
 
// Валюты
$currencies = $simpla->money->get_currencies(array('enabled'=>1));
$main_currency = reset($currencies);
/*foreach($currencies as $c1) {
if($c1->code == "GRN") {
    $r_from = $c1->rate_from;
}  
}*/
/*foreach($currencies as $c) {
if($c->enabled){
if($c->code == "USD") {   
print "\n<currency code='".$c->code."' rate='".$r_from."'/>
";
}
}
}*/
 
// Категории
$categories = $simpla->categories->get_categories();
print "<catalog>
";
foreach($categories as $c)
{
if($c->visible) {
print "\t<category id='".$c->id."'";
if($c->parent_id>0) {
    print " parentID='".$c->parent_id."'";
}
print ">".htmlspecialchars($c->name)."</category>
";
}
}
print "</catalog>
";
 
// Товары
$simpla->db->query("SET SQL_BIG_SELECTS=1");
// Товары
$simpla->db->query("SELECT v.price, v.id as variant_id, p.name as product_name, p.brand_id as brand_id, v.name as variant_name, v.position as variant_position, p.id as product_id, p.url, p.annotation, pc.category_id, i.filename as image, b.name as brand_name
                    FROM __variants v LEFT JOIN __products p ON v.product_id=p.id
                    LEFT JOIN __brands b ON p.brand_id = b.id
                    LEFT JOIN __products_categories pc ON p.id = pc.product_id AND pc.position=(SELECT MIN(position) FROM __products_categories WHERE product_id=p.id LIMIT 1)    
                    LEFT JOIN __images i ON p.id = i.product_id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1)    
                    WHERE p.visible AND (v.stock >0 OR v.stock is NULL) GROUP BY v.id ORDER BY p.id, v.position ");
print "<items>
";
$currency_code = reset($currencies)->code;
 
// В цикле мы используем не results(), a result(), то есть выбираем из базы товары по одному,
// так они нам одновременно не нужны - мы всё равно сразу же отправляем товар на вывод.
// Таким образом используется памяти только под один товар
$prev_product_id = null;
while($p = $simpla->db->result())
{
$variant_url = '';
if ($prev_product_id === $p->product_id)
    $variant_url = '?variant='.$p->variant_id;
$prev_product_id = $p->product_id;
 
$price = $p->price;//round($simpla->money->convert($p->price, $main_currency->id, false),2);
print
"\t<item id='".$p->variant_id."'>
\t<name>".htmlspecialchars($p->product_name).' '.($p->variant_name?''.htmlspecialchars($p->variant_name):'')."</name>
\t<categoryId>".$p->category_id."</categoryId>
\t<price>".$price."</price>
\t<url>".$simpla->config->root_url.'/products/'.$p->url.$variant_url."</url>
";
if($p->image) {
print "\t<image>".$simpla->design->resize_modifier($p->image, 200, 200)."</image>
";}
print "\t<vendor>".$p->brand_name."</vendor>
";
print "\t<description>".htmlspecialchars(strip_tags($p->body))."</description>
\t</item>
";
}
 
print "</items>
";
print "</price>
";
 
 
Если что-то много нужно поправлять - то я могу заплатить  :)
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...