adding archive items download (#26)
This commit is contained in:
parent
e9e405781d
commit
0173c71033
@ -101,8 +101,10 @@ class MoySkladICMLParser
|
||||
}
|
||||
|
||||
$icml = $this->ICMLCreate($categories, $assortiment);
|
||||
|
||||
$icml->asXML($this->getFilePath());
|
||||
|
||||
if (count($categories) > 0 && count($assortiment) > 0) {
|
||||
$icml->asXML($this->getFilePath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -221,13 +223,19 @@ class MoySkladICMLParser
|
||||
|
||||
$offset = 0;
|
||||
$end = null;
|
||||
$url = self::ASSORT_LIST_URL.'?expand='.self::ASSORTIMENT_EXPAND.'&limit='.self::LIMIT;
|
||||
|
||||
$ignoreNoCategoryOffers = isset($this->options['ignoreNoCategoryOffers']) && $this->options['ignoreNoCategoryOffers'];
|
||||
|
||||
$ignoreCategories = $this->getIgnoreProductGroupsInfo();
|
||||
|
||||
if (isset($this->options['archivedGoods']) && $this->options['archivedGoods'] === true) {
|
||||
$url .= '&archived=All';
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
||||
$response = $this->requestJson(self::ASSORT_LIST_URL.'?expand='.self::ASSORTIMENT_EXPAND.'&limit='.self::LIMIT.'&offset='.$offset);
|
||||
$response = $this->requestJson($url.'&offset='.$offset);
|
||||
|
||||
if ($response && $response['rows']) {
|
||||
foreach ($response['rows'] as $assortiment) {
|
||||
|
@ -45,6 +45,8 @@ c) `shopname` заменить на название Вашего магазин
|
||||
|
||||
d) в строке `'file' => 'test.xml'`, заменить `test.xml` на любое другое название (например, `catalog.xml`, расширение файла оставить то же), либо оставить без изменения.
|
||||
|
||||
e) При необходимости включения в генерацию архивных товаров и модификаций в строке `'archivedGoods' => false` необходимо заменить значение `false` на `true`.
|
||||
|
||||
4) После настройки добавить задачу в cron: `* */4 * * * php /путь_к_файлу_скрипта/example.php` (данная запись подразумевает автоматический запуск генерации файла каталога каждый день раз в 4 часа).
|
||||
|
||||
5) Запустить генерацию вручную (командой `php /путь_к_файлу_скрипта/example.php`), чтобы в папке со скриптом появился файл каталога в формате xml.
|
||||
@ -57,6 +59,7 @@ d) в строке `'file' => 'test.xml'`, заменить `test.xml` на лю
|
||||
|
||||
* `file` - Имя файла с итоговым icml без пути (по умолчанию: shopname.catalog.xml)
|
||||
* `directory` - Директория для итогового icml файла (по умолчанию: текущая директория)
|
||||
* `'archivedGoods'` - опция для включения в генерацию архивных товаров и торговых предложений (принимает значения `true` или `false`)
|
||||
* `ignoreCategories` - массив с ключами:
|
||||
* `ids` - Массив c `id` групп товаров, которые должны быть проигнорированы
|
||||
* `externalCodes` - Массив c `внешними кодами` групп товаров, которые должны быть проигнорированы
|
||||
@ -76,4 +79,4 @@ d) в строке `'file' => 'test.xml'`, заменить `test.xml` на лю
|
||||
* Application website - URL сайта
|
||||
* Email - email администаротора сайта
|
||||
* Description - Описание сайта
|
||||
После создания приложения отобразится два поля `Client ID` и `Client secret`. Нам потребуется только `Client ID` который требуется вставить в $options.
|
||||
После создания приложения отобразится два поля `Client ID` и `Client secret`. Нам потребуется только `Client ID` который требуется вставить в $options.
|
||||
|
@ -27,9 +27,10 @@ Options is array with next keys:
|
||||
|
||||
* `file` - filename with result icml without path (default: shopname.catalog.xml)
|
||||
* `directory` - target directory for icml file (default: current directory)
|
||||
* `'archivedGoods'` - option for inclusion in the generation of archived goods and trade offers (takes the values of `true` or` false`)
|
||||
* `ignoreCategories` - array with keys:
|
||||
* `ids` - array with GoodFolder `id` for ignore
|
||||
* `externalCodes` - array with GoodFolder `externalcode` for ignore
|
||||
* `ignoreNoCategoryOffers` - If `true` goods that do not belong to any category are ignored
|
||||
|
||||
All options keys aren't required
|
||||
All options keys aren't required
|
||||
|
@ -10,8 +10,9 @@ $parser = new MoySkladICMLParser(
|
||||
array(
|
||||
'directory' => __DIR__,
|
||||
'file' => 'test.xml',
|
||||
'archivedGoods' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// generate
|
||||
$parser->generateICML();
|
||||
$parser->generateICML();
|
||||
|
Loading…
x
Reference in New Issue
Block a user