Skip to content

Commit

Permalink
ref #95389 Support for services in ICML (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
uryvskiy-dima authored May 13, 2024
1 parent 3d6edb8 commit bf9f07a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 12 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/presta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
strategy:
matrix:
include:
- php-version: '7.1'
branch: '1.7.7.0'
composerv1: 1
- php-version: '7.2'
branch: '1.7.7.0'
composerv1: 1
# - php-version: '7.1' - Warning: Invalid argument supplied for foreach() in /home/runner/work/prestashop-module/PrestaShop/classes/Language.php
# branch: '1.7.7.0'
# composerv1: 1
# - php-version: '7.2' - Warning: Invalid argument supplied for foreach() in /home/runner/work/prestashop-module/PrestaShop/classes/Language.php
# branch: '1.7.7.0'
# composerv1: 1
- php-version: '7.3'
branch: '1.7.7.0'
composerv1: 1
- php-version: '7.1'
branch: '1.7.8.10'
coverage: 1
# - php-version: '7.1' - Error install PrestaShop
# branch: '1.7.8.10'
- php-version: '7.2'
branch: '1.7.8.10'
coverage: 1
- php-version: '7.3'
branch: '1.7.8.10'
services:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v3.6.4
* Добавлена передача услуг через ICML каталог

## v3.6.3
* Исправление активации/деактивации модуля

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.3
3.6.4
6 changes: 6 additions & 0 deletions retailcrm/lib/RetailcrmCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ function ($val) use ($inactiveCategories, $categoriesIds) {
$dimensions = null;
}

$useServices = RetailcrmTools::isIcmlServicesEnabled()
&& !empty($product['is_virtual'])
&& empty($product['uploadable_files']);

$offers = Product::getProductAttributesIds($product['id_product']);
$features = Product::getFrontFeaturesStatic($id_lang, $product['id_product']);

Expand Down Expand Up @@ -276,6 +280,7 @@ function ($val) use ($inactiveCategories, $categoriesIds) {

$item = [
'id' => $product['id_product'] . '#' . $offer['id_product_attribute'],
'type' => $useServices ? 'service' : 'product',
'productId' => $product['id_product'],
'productActivity' => ($available_for_order) ? 'Y' : 'N',
'name' => ('' === $name) ? $productName : $name,
Expand Down Expand Up @@ -334,6 +339,7 @@ function ($val) use ($inactiveCategories, $categoriesIds) {
'RetailcrmFilterProcessOffer',
[
'id' => $product['id_product'],
'type' => $useServices ? 'service' : 'product',
'productId' => $product['id_product'],
'productActivity' => ($available_for_order) ? 'Y' : 'N',
'name' => $productName,
Expand Down
1 change: 1 addition & 0 deletions retailcrm/lib/RetailcrmIcml.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ private function addOffers($offers)
$this->writer->startElement('offer'); // start <offer>

$this->writer->writeAttribute('id', $offer['id']);
$this->writer->writeAttribute('type', $offer['type']);
$this->writer->writeAttribute('productId', $offer['productId']);
$this->writer->writeAttribute('quantity', (int) $offer['quantity']);

Expand Down
10 changes: 10 additions & 0 deletions retailcrm/lib/RetailcrmTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public static function isCorporateEnabled()
return (bool) Configuration::get(RetailCRM::ENABLE_CORPORATE_CLIENTS);
}

/**
* Returns true if ICML service transfer is enabled in the settings
*
* @return bool
*/
public static function isIcmlServicesEnabled()
{
return (bool) Configuration::get(RetailCRM::ENABLE_ICML_SERVICES);
}

/**
* Returns true if customer is corporate
*
Expand Down
1 change: 1 addition & 0 deletions retailcrm/lib/settings/RetailcrmSettingsItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function __construct()
'enableBalancesReceiving' => new RetailcrmSettingsItemBool('enableBalancesReceiving', RetailCRM::ENABLE_BALANCES_RECEIVING),
'collectorActive' => new RetailcrmSettingsItemBool('collectorActive', RetailCRM::COLLECTOR_ACTIVE),
'synchronizeCartsActive' => new RetailcrmSettingsItemBool('synchronizeCartsActive', RetailCRM::SYNC_CARTS_ACTIVE),
'enableIcmlServices' => new RetailcrmSettingsItemBool('enableIcmlServices', RetailCRM::ENABLE_ICML_SERVICES),
'enableCorporate' => new RetailcrmSettingsItemBool('enableCorporate', RetailCRM::ENABLE_CORPORATE_CLIENTS),
'enableOrderNumberSending' => new RetailcrmSettingsItemBool('enableOrderNumberSending', RetailCRM::ENABLE_ORDER_NUMBER_SENDING),
'enableOrderNumberReceiving' => new RetailcrmSettingsItemBool('enableOrderNumberReceiving', RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING),
Expand Down
4 changes: 3 additions & 1 deletion retailcrm/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class RetailCRM extends Module
{
const VERSION = '3.6.3';
const VERSION = '3.6.4';

const API_URL = 'RETAILCRM_ADDRESS';
const API_KEY = 'RETAILCRM_API_TOKEN';
Expand All @@ -66,6 +66,7 @@ class RetailCRM extends Module
const SYNC_CARTS_DELAY = 'RETAILCRM_API_SYNCHRONIZED_CART_DELAY';
const UPLOAD_ORDERS = 'RETAILCRM_UPLOAD_ORDERS_ID';
const MODULE_LIST_CACHE_CHECKSUM = 'RETAILCRM_MODULE_LIST_CACHE_CHECKSUM';
const ENABLE_ICML_SERVICES = 'RETAILCRM_ENABLE_ICML_SERVICES';
const ENABLE_CORPORATE_CLIENTS = 'RETAILCRM_ENABLE_CORPORATE_CLIENTS';
const ENABLE_HISTORY_UPLOADS = 'RETAILCRM_ENABLE_HISTORY_UPLOADS';
const ENABLE_BALANCES_RECEIVING = 'RETAILCRM_ENABLE_BALANCES_RECEIVING';
Expand Down Expand Up @@ -336,6 +337,7 @@ public function uninstall()
&& Configuration::deleteByName(static::SYNC_CARTS_DELAY)
&& Configuration::deleteByName(static::UPLOAD_ORDERS)
&& Configuration::deleteByName(static::MODULE_LIST_CACHE_CHECKSUM)
&& Configuration::deleteByName(static::ENABLE_ICML_SERVICES)
&& Configuration::deleteByName(static::ENABLE_CORPORATE_CLIENTS)
&& Configuration::deleteByName(static::ENABLE_HISTORY_UPLOADS)
&& Configuration::deleteByName(static::ENABLE_BALANCES_RECEIVING)
Expand Down
2 changes: 1 addition & 1 deletion retailcrm/views/js/app.js

Large diffs are not rendered by default.

0 comments on commit bf9f07a

Please sign in to comment.