Ответить Новая тема Новый опрос 
 Помогите разобраться со скриптом
naff
Cпециалист
Сообщений: 216
Регистрация: 05-09-2011


04-10-2011 00:07
Есть скрипт - он генерирует XML файл для Яндекс.Каталога.
Категории он заполняет а вот с товаром проблема...

В чем проблема подскажите:
Код:
//   Выборка продуктов с атрибутами
                $result_fld_items = mysql_query( "
                                        SELECT     id_category_default,name,description_short,
                                        ps_product.price,ps_product_attribute.quantity,reduction_price,
                                        id_manufacturer,ps_product.id_product,
                                        id_product_attribute,ps_product_attribute.price
                                        FROM( (ps_product RIGHT JOIN ps_product_lang on ps_product.id_product= ps_product_lang.id_product)
                                                          RIGHT JOIN ps_product_attribute ON ps_product.id_product=ps_product_attribute.id_product)
                                        where id_lang =$id_lang
                                        GROUP BY id_product_attribute
                                                ", $dbhandle );
                while( $row2 = mysql_fetch_row($result_fld_items) ) {
                    //active state category tracking
                    $result_astate = mysql_query("
                                                    SELECT active from ps_category where id_category = $row2[0]
                                                    ");
                    $row_result_astate = mysql_fetch_row($result_astate);
                    if($row_result_astate[0]) {
                    //if($row2[4]) {
                                
                                        $output .= "\n\t<item>";
                                          $output .= "\n\t\t<categoryId>$row2[0]</categoryId>";
                                          if($row2[6] !=0){
                                                $result_fld_vendor = mysql_query( "SELECT name FROM ps_manufacturer where id_manufacturer=$row2[6]");
                                                $row3 = mysql_fetch_row($result_fld_vendor);
                                                $output .= "\n\t\t<vendor>$row3[0]</vendor>";
                                          }
                                          else  {
                                                $output .= "\n\t\t<vendor>нет</vendor>";
                                          }
                                          
                                                //$result_fld_attrname = mysql_query( "SELECT name FROM ps_attribute_lang where id_attribute=$row2[8] AND id_lang =$id_lang ");
                                                $result_fld_attrname = mysql_query( "
                                                                    SELECT name
                                                                    FROM  ps_attribute_lang RIGHT JOIN ps_product_attribute_combination
                                                                    ON  ps_attribute_lang.id_attribute = ps_product_attribute_combination.id_attribute
                                                                    Where  id_lang =$id_lang and id_product_attribute = $row2[8]
                                                ");
                                                $row_attr_name = mysql_fetch_row($result_fld_attrname);
                                          //$output .= "\n\t\t<name>$row2[1] attrID>> $row2[8]  </name>";        
                                          //$output .= "\n\t\t<name>$row2[1] - $row_attr_name[0] -($row2[8])</name>";        
                                          $output .= "\n\t\t<name>$row2[1] $row_attr_name[0]</name>";        
                                          // descrition cutting
                                          $strdesc_1 = $row2[2];
                                          $strdesc_1 = str_replace("<p>","",$strdesc_1);
                                          $strdesc_1 = str_replace("</p>","",$strdesc_1);
                                          $strdesc_1 = str_replace("<strong>","",$strdesc_1);
                                          $strdesc_1 = str_replace("</strong>","",$strdesc_1);
                                          
                                          $output .= "\n\t\t<description>$strdesc_1</description>";        
                                          $srvname1 = $_SERVER['HTTP_HOST' ];
                                          $output .= "\n\t\t<url> http://$srvname1/product.php?id_product=$row2[7]</url>";    
                                           $UAPRICE = $row2[3] + $row2[9]                       ;
                                          $output .= "\n\t\t<priceRUAH>$UAPRICE</priceRUAH>";        
                                                //$output .= "\n\t\t<priceRUSD>".($row2[3]/$rate1)."</priceRUSD>";    
                                          $output .= "\n\t\t<priceRUSD>".($UAPRICE/$rate1)."</priceRUSD>";        
                                                //$output .= "\n\t\t<priceROSD>".($row2[3]/$rate1-($row2[3]/$rate1/100)*$xml_rduction_percent)."</priceROSD>";        
                                          $output .= "\n\t\t<priceROSD>".($UAPRICE/$rate1-($UAPRICE/$rate1/100)*$xml_rduction_percent)."</priceROSD>";        
                                          if($row2[4]){
                                                        if($row2[4]>2)
                                                          $output .= "\n\t\t<stock>На складе</stock>";
                                                        if($row2[4]<=2 && $row2[4] !=0 )
                                                         $output .= "\n\t\t<stock>Уточняйте</stock>";
                                                        if($row2[4] ==0 )
                                                         $output .= "\n\t\t<stock>Под заказ</stock>";
                                               }
                                                else $output .= "\n\t\t<stock>Под заказ</stock>";

                                            //      if($row2[4]>0 && $row2[4]<3) $output .= "\n\t\t<stock>Уточняйте</stock>";
                                            //      if(!$row2[4]) $output .= "\n\t\t<stock>Под заказ</stock>";
                                            //      if($row2[4]>2) $output .= "\n\t\t<stock>На складе</stock>";
                                            
                                          //$output .= "\n\t\t<stock>$row2[4]</stock>";
                                          $gar1 = "нет";
                                          //iconv("CP1251", "UTF-8",$gar1);
                                          //iconv("UTF-8","CP1251",$gar1);
                                          
                                            foreach($varanti as $vv1=>$vv2)
                                            {
                                              if($vv1 == $row2[0])  $gar1 = 12*$vv2;
                                            }
                                          $output .= "\n\t\t<guarantee>$gar1</guarantee>";        
                                          $output .= "\n\t</item>";  
                                          
                                }//if active        
                                $i++;        
                       }                


Весь товар на сайте с атрибутами...

Заранее благодарен

 
Вне форума
ПМ Отправить эл.сообщение 
Щелкните, и это сообщение будет добавлено в ваш ответ как цитата Цитировать этот ответ
naff
Cпециалист
Сообщений: 216
Регистрация: 05-09-2011


08-10-2011 17:03
Переделал скрипт... Может кому пригодится.
Скрипт генерирует XML файл для Яндекс.Маркета.
Скрипт не универсальный, по этому если будут проблемы пишите подскаже что поправить....
Что бы запустить его:
Закидуете скрипт в корень сайта;
В адресной строке пишете /свой_сайт/_xml.php?idxmllang=6
idxmllang - это ваш id языка описания.


Вложения:

Вложения _xml.php( Размер файла: 6.21KB Скачиваний: 379 )
 
Вне форума
ПМ Отправить эл.сообщение 
Щелкните, и это сообщение будет добавлено в ваш ответ как цитата Цитировать этот ответ
Ответить Новая тема Новый опрос