Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regions = [
- 'Челябинск' => 22160,
- 'Екатеринбург' => 22130,
- 'Тюмень' => 45045,
- 'Курган' => 45053,
- 'Москва' => 53369,
- 'Уфа' => 45054
- ];
- $arrPriceType = [];
- foreach ($regions as $region) {
- $sql = "SELECT * FROM `b_iblock_element_prop_s6` where IBLOCK_ELEMENT_ID = " . $region;
- $sql_db = $DB->Query($sql);
- while ($regi = $sql_db->Fetch()) {
- $arrPriceType[$region] = $regi['PROPERTY_87'];
- }
- }
- $sects = "SELECT ID, CODE, NAME, DESCRIPTION, IBLOCK_SECTION_ID FROM `b_iblock_section` where IBLOCK_ID = 4 and ACTIVE='Y'";
- $sects_db = $DB->Query($sects);
- while ($sect = $sects_db->Fetch()) {
- $product_sql = 'SELECT * from b_iblock_element WHERE ACTIVE = "Y" and IBLOCK_ID=4 and IBLOCK_SECTION_ID='.$sect["ID"];
- $product_db = $DB->Query($product_sql);
- while ($product = $product_db->Fetch()){
- $offers = get_product_offers($product['ID']);
- foreach ($offers as $offer) {
- $prices = get_prices($offer);
- foreach ($prices as $price) {
- foreach ($arrPriceType as $reg => $priceType) {
- if($price["PRICE_TYPE_ID"] == $priceType) {
- if (empty($actual_price[$sect["ID"]][$reg]) || $actual_price[$sect["ID"]][$reg] > $price['NEW']) {
- $actual_price[$sect["ID"]][$reg] = $price['NEW'];
- }
- }
- }
- }
- }
- }
- foreach ($actual_price[$sect["ID"]] as $key => $pr) {
- $response .= '<offer id="S' . $sect['ID'] . '-'. $key .'" available="true">';
- $response .= '<url><![CDATA[https://hypermarketmebel.ru/catalog/' . $sect['CODE'] . '?sr='.$key.']]></url>';
- $response .= '<price>' . $pr . '</price>';
- $response .= '<currencyId>RUB</currencyId>';
- $response .= '<name><![CDATA[' . $sect['NAME'] . ']]></name>';
- $response .= !empty($sect['DESCRIPTION']) ? '<description><![CDATA['.$sect['DESCRIPTION'].']]></description>' : '';
- $response .= '</offer>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement