mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-04-11 12:50:55 +00:00
ref #95389 Support for services in ICML
This commit is contained in:
parent
3d6edb8b97
commit
83e5f4087a
7 changed files with 22 additions and 84 deletions
|
@ -207,6 +207,11 @@ class RetailcrmCatalog
|
|||
$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']);
|
||||
|
||||
|
@ -276,6 +281,7 @@ class RetailcrmCatalog
|
|||
|
||||
$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,
|
||||
|
@ -334,6 +340,7 @@ class RetailcrmCatalog
|
|||
'RetailcrmFilterProcessOffer',
|
||||
[
|
||||
'id' => $product['id_product'],
|
||||
'type' => $useServices ? 'service' : 'product',
|
||||
'productId' => $product['id_product'],
|
||||
'productActivity' => ($available_for_order) ? 'Y' : 'N',
|
||||
'name' => $productName,
|
||||
|
|
|
@ -181,6 +181,7 @@ class RetailcrmIcml
|
|||
$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']);
|
||||
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2021 DIGITAL RETAIL TECHNOLOGIES SL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
|
||||
* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL
|
||||
* @license https://opensource.org/licenses/MIT The MIT License
|
||||
*
|
||||
* Don't forget to prefix your containers with your own identifier
|
||||
* to avoid any conflicts with others containers.
|
||||
*/
|
||||
|
||||
class RetailcrmInventories
|
||||
{
|
||||
/**
|
||||
* @var \RetailcrmProxy|\RetailcrmApiClientV5
|
||||
*/
|
||||
public static $api;
|
||||
|
||||
/**
|
||||
* Load stock from retailCRM
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadStocks()
|
||||
{
|
||||
$page = 1;
|
||||
|
||||
do {
|
||||
$result = self::$api->storeInventories([], $page, 250);
|
||||
|
||||
if (false === $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($result['offers'] as $offer) {
|
||||
self::setQuantityOffer($offer);
|
||||
}
|
||||
|
||||
$totalPageCount = $result['pagination']['totalPageCount'];
|
||||
++$page;
|
||||
} while ($page <= $totalPageCount);
|
||||
}
|
||||
|
||||
private static function setQuantityOffer($offer)
|
||||
{
|
||||
if (isset($offer['externalId'])) {
|
||||
$invOffer = explode('#', $offer['externalId']);
|
||||
|
||||
if (isset($invOffer[1])) {
|
||||
StockAvailable::setQuantity($invOffer[0], $invOffer[1], $offer['quantity']);
|
||||
} else {
|
||||
StockAvailable::setQuantity($offer['externalId'], 0, $offer['quantity']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,6 +68,16 @@ class RetailcrmTools
|
|||
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
|
||||
*
|
||||
|
|
|
@ -58,6 +58,7 @@ class RetailcrmSettingsItems
|
|||
'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),
|
||||
|
|
|
@ -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';
|
||||
|
@ -336,6 +337,7 @@ class RetailCRM extends Module
|
|||
&& 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)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue