Advertisement
Guest User

Untitled

a guest
May 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. $regions = [
  2.     'Челябинск' => 22160,
  3.     'Екатеринбург' => 22130,
  4.     'Тюмень' => 45045,
  5.     'Курган' => 45053,
  6.     'Москва' => 53369,
  7.     'Уфа' => 45054
  8. ];
  9. $arrPriceType = [];
  10. foreach ($regions as $region) {
  11.     $sql = "SELECT * FROM `b_iblock_element_prop_s6` where IBLOCK_ELEMENT_ID = " . $region;
  12.     $sql_db = $DB->Query($sql);
  13.     while ($regi = $sql_db->Fetch()) {
  14.         $arrPriceType[$region] = $regi['PROPERTY_87'];
  15.     }
  16. }
  17.  
  18. $sects = "SELECT ID, CODE, NAME, DESCRIPTION, IBLOCK_SECTION_ID FROM `b_iblock_section` where IBLOCK_ID = 4 and ACTIVE='Y'";
  19. $sects_db = $DB->Query($sects);
  20. while ($sect = $sects_db->Fetch()) {
  21.     $product_sql = 'SELECT * from b_iblock_element WHERE ACTIVE = "Y" and IBLOCK_ID=4 and IBLOCK_SECTION_ID='.$sect["ID"];
  22.     $product_db = $DB->Query($product_sql);
  23.     while ($product = $product_db->Fetch()){
  24.         $offers = get_product_offers($product['ID']);
  25.         foreach ($offers as $offer) {
  26.             $prices = get_prices($offer);
  27.             foreach ($prices as $price) {
  28.                 foreach ($arrPriceType as $reg => $priceType) {
  29.                     if($price["PRICE_TYPE_ID"] == $priceType) {
  30.                         if (empty($actual_price[$sect["ID"]][$reg]) || $actual_price[$sect["ID"]][$reg] > $price['NEW']) {
  31.                             $actual_price[$sect["ID"]][$reg] = $price['NEW'];
  32.                         }
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     foreach ($actual_price[$sect["ID"]] as $key => $pr) {
  39.         $response .= '<offer id="S' . $sect['ID'] . '-'. $key .'" available="true">';
  40.         $response .= '<url><![CDATA[https://hypermarketmebel.ru/catalog/' . $sect['CODE'] . '?sr='.$key.']]></url>';
  41.         $response .= '<price>' . $pr . '</price>';
  42.         $response .= '<currencyId>RUB</currencyId>';
  43.         $response .= '<name><![CDATA[' . $sect['NAME'] . ']]></name>';
  44.         $response .= !empty($sect['DESCRIPTION']) ? '<description><![CDATA['.$sect['DESCRIPTION'].']]></description>' : '';
  45.         $response .= '</offer>';
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement