mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-02 19:33:14 +03:00
Fix icml category generation
This commit is contained in:
parent
302c6dd18c
commit
bfa41b7d14
@ -1,3 +1,6 @@
|
|||||||
|
## v3.0.4
|
||||||
|
* Проверка корректности генерации категорий в ICML
|
||||||
|
|
||||||
## v3.0.3
|
## v3.0.3
|
||||||
* Исправлена ошибка при обновлении со старой версии для некоторых клиентов
|
* Исправлена ошибка при обновлении со старой версии для некоторых клиентов
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ class RetailcrmCatalog
|
|||||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||||
$shop_url = (Configuration::get('PS_SSL_ENABLED') ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
$shop_url = (Configuration::get('PS_SSL_ENABLED') ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
|
||||||
$protocol = (Configuration::get('PS_SSL_ENABLED')) ? "https://" : "http://";
|
$protocol = (Configuration::get('PS_SSL_ENABLED')) ? "https://" : "http://";
|
||||||
|
$homeCategory = Configuration::get('PS_HOME_CATEGORY');
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
$categories = array();
|
$categories = array();
|
||||||
@ -71,29 +72,41 @@ class RetailcrmCatalog
|
|||||||
$types = Category::getCategories($id_lang, true, false);
|
$types = Category::getCategories($id_lang, true, false);
|
||||||
|
|
||||||
foreach ($types as $category) {
|
foreach ($types as $category) {
|
||||||
if (!self::isCategoryActive(new Category($category['id_category']))) {
|
$categoryId = (empty($category['id_category']) && isset($category['id']))
|
||||||
if (!in_array($category['id_category'], $inactiveCategories)) {
|
? $category['id'] : $category['id_category'];
|
||||||
$inactiveCategories[] = $category['id_category'];
|
|
||||||
|
if (!self::isCategoryActive(new Category($categoryId))) {
|
||||||
|
if (!in_array($categoryId, $inactiveCategories)) {
|
||||||
|
$inactiveCategories[] = $categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$picture = $link->getCatImageLink($category['link_rewrite'], $category['id_category'], 'category_default');
|
$picture = $link->getCatImageLink($category['link_rewrite'], $categoryId, 'category_default');
|
||||||
|
|
||||||
$categoriesIds[] = $category['id_category'];
|
$categoriesIds[] = $categoryId;
|
||||||
$categories[] = array(
|
$categories[] = array(
|
||||||
'id' => $category['id_category'],
|
'id' => $categoryId,
|
||||||
'parentId' => $category['id_parent'],
|
'parentId' => self::getParentCategoryId($category['id_parent']),
|
||||||
'name' => $category['name'],
|
'name' => $category['name'],
|
||||||
'picture' => $picture ? $protocol . $picture : ''
|
'picture' => $picture ? $protocol . $picture : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($categories as $key => $innerCategory) {
|
||||||
|
if (isset($innerCategory['parentId'])
|
||||||
|
&& !empty($innerCategory['parentId'])
|
||||||
|
&& !in_array($innerCategory['parentId'], $categoriesIds)
|
||||||
|
) {
|
||||||
|
$innerCategory['parentId'] = $homeCategory;
|
||||||
|
$categories[$key] = $innerCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$products = Product::getProducts($id_lang, 0, 0, 'name', 'asc');
|
$products = Product::getProducts($id_lang, 0, 0, 'name', 'asc');
|
||||||
|
|
||||||
foreach ($products AS $product) {
|
foreach ($products AS $product) {
|
||||||
$homeCategory = Configuration::get('PS_HOME_CATEGORY');
|
|
||||||
$category = $product['id_category_default'];
|
$category = $product['id_category_default'];
|
||||||
|
|
||||||
if (!in_array($category, $categoriesIds)) {
|
if (!in_array($category, $categoriesIds)) {
|
||||||
@ -315,4 +328,33 @@ class RetailcrmCatalog
|
|||||||
|
|
||||||
return $category->active;
|
return $category->active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns active parent category
|
||||||
|
*
|
||||||
|
* @param int $parentId
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
private static function getParentCategoryId($parentId)
|
||||||
|
{
|
||||||
|
$home = Configuration::get('PS_HOME_CATEGORY');
|
||||||
|
|
||||||
|
if (empty($parentId)) {
|
||||||
|
return $home;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($parentId == $home) {
|
||||||
|
return $home;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var \Category|\CategoryCore $category */
|
||||||
|
$category = new Category($parentId);
|
||||||
|
|
||||||
|
if (empty($category->id) || !$category->active) {
|
||||||
|
return $home;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parentId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,13 +167,6 @@ class RetailcrmJobManager
|
|||||||
$exception->getTraceAsString(),
|
$exception->getTraceAsString(),
|
||||||
$job
|
$job
|
||||||
);
|
);
|
||||||
} catch (\Throwable $throwable) {
|
|
||||||
static::handleError(
|
|
||||||
$throwable->getFile(),
|
|
||||||
$throwable->getMessage(),
|
|
||||||
$throwable->getTraceAsString(),
|
|
||||||
$job
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,8 +281,6 @@ class RetailcrmJobManager
|
|||||||
static::execHere($fileCommandLine, $once);
|
static::execHere($fileCommandLine, $once);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
throw new RetailcrmJobManagerException($exception->getMessage(), $fileCommandLine);
|
throw new RetailcrmJobManagerException($exception->getMessage(), $fileCommandLine);
|
||||||
} catch (\Throwable $exception) {
|
|
||||||
throw new RetailcrmJobManagerException($exception->getMessage(), $fileCommandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class RetailCRM extends Module
|
|||||||
{
|
{
|
||||||
$this->name = 'retailcrm';
|
$this->name = 'retailcrm';
|
||||||
$this->tab = 'export';
|
$this->tab = 'export';
|
||||||
$this->version = '3.0.3';
|
$this->version = '3.0.4';
|
||||||
$this->author = 'DIGITAL RETAIL TECHNOLOGIES SL';
|
$this->author = 'DIGITAL RETAIL TECHNOLOGIES SL';
|
||||||
$this->displayName = $this->l('retailCRM');
|
$this->displayName = $this->l('retailCRM');
|
||||||
$this->description = $this->l('Integration module for retailCRM');
|
$this->description = $this->l('Integration module for retailCRM');
|
||||||
@ -1102,12 +1102,6 @@ class RetailCRM extends Module
|
|||||||
RetailcrmLogger::writeNoCaller($exception->getTraceAsString());
|
RetailcrmLogger::writeNoCaller($exception->getTraceAsString());
|
||||||
Configuration::updateValue(static::MODULE_LIST_CACHE_CHECKSUM, 'exception');
|
Configuration::updateValue(static::MODULE_LIST_CACHE_CHECKSUM, 'exception');
|
||||||
|
|
||||||
return static::getCachedCmsModulesList();
|
|
||||||
} catch (Throwable $throwable) {
|
|
||||||
RetailcrmLogger::writeCaller(__METHOD__, $throwable->getMessage());
|
|
||||||
RetailcrmLogger::writeNoCaller($throwable->getTraceAsString());
|
|
||||||
Configuration::updateValue(static::MODULE_LIST_CACHE_CHECKSUM, 'throwable');
|
|
||||||
|
|
||||||
return static::getCachedCmsModulesList();
|
return static::getCachedCmsModulesList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user