Ejemplo n.º 1
0
        preg_match('|\\<picture\\>(.+)\\</picture\\>|', $product, $matches);
        $image = @$matches[1];
        preg_match('|\\<name\\>(.+)\\</name\\>|', $product, $matches);
        $title = @$matches[1];
        $title = str_replace('<![CDATA[', '', $title);
        $title = str_replace(']]>', '', $title);
        if (!$title && preg_match('|\\<model\\>(.+)\\</model\\>|', $product, $matches)) {
            $title = @$matches[1];
            $title = str_replace('<![CDATA[', '', $title);
            $title = str_replace(']]>', '', $title);
        }
        $ps = mb_strpos($product, '<description>', 0, 'utf-8');
        $pe = mb_strpos($product, '</description>', 0, 'utf-8');
        $descr = mb_substr($product, $ps + mb_strlen('<description>', 'utf-8'), $pe - $ps - mb_strlen('<description>', 'utf-8'), 'utf-8');
        $descr = str_replace('<![CDATA[', '', $descr);
        $descr = str_replace(']]>', '', $descr);
        preg_match('|\\<categoryId\\>(.+)\\</categoryId\\>|', $product, $matches);
        $categoryId = @$matches[1];
        //обновление поста
        importPost(array('id' => $id, 'title' => $title, 'description' => nl2br($descr), 'url' => $url, 'price' => $price, 'currency' => $currency, 'image' => $image, 'category_id' => $categoryId), GdeSlonImport::parseParams($product));
        unset($content);
    } else {
        break;
    }
}
fclose($f);
@unlink($path . '/' . $xmlfile);
flushCache($cats);
wp_mail(get_option('admin_email'), 'Обновление товаров', 'Обновление товаров завершено!');
echo "Done!\n";
exit;