mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
v2.2.8
This commit is contained in:
parent
2ce4158c02
commit
e5bd5f6adc
17
CHANGELOG.md
17
CHANGELOG.md
@ -1,27 +1,30 @@
|
||||
## v.2.2.7
|
||||
## v2.2.8
|
||||
* Добавлена выгрузка картинок категорий товаров в ICML
|
||||
|
||||
## v2.2.7
|
||||
* Добавлена отправка адреса клиента при обновлении покупателя на стороне сайта
|
||||
* Добавлены методы получения адреса и телефона
|
||||
|
||||
## v.2.2.6
|
||||
## v2.2.6
|
||||
* Добавлена активация модуля в маркетплейсе retailCRM
|
||||
|
||||
## v.2.2.5
|
||||
## v2.2.5
|
||||
* Добавлена передача страны при создании заказа для пользователя и заказа
|
||||
* Добавлен метод сохранения сущностей с обработкой исключений
|
||||
|
||||
## v.2.2.4
|
||||
## v2.2.4
|
||||
* Добавлена установка дефолтной валюты для оплаты при получении истории
|
||||
* Добавлено получение суммы оплаты из заказа в CMS, если она не передается по истории
|
||||
|
||||
## v.2.2.3
|
||||
## v2.2.3
|
||||
* добавлена обработка исключений при обновлении пользователя на стороне CMS
|
||||
|
||||
## v.2.2.2
|
||||
## v2.2.2
|
||||
* Добавлена передача комментария клиента при создании заказа
|
||||
* Добавлена передача дополнительного номера телефона в заказе и клиенте при создании заказа
|
||||
* Добавлен перевод на испанкий язык
|
||||
|
||||
## v.2.2.0
|
||||
## v2.2.0
|
||||
* Добавлена выгрузка истории изменений по клиентам
|
||||
* Добавлена проверка имени и значения свойств товара перед отправкой заказа
|
||||
* Выгрузка изменений из СРМ теперь происходит по идетификатору истории
|
||||
|
@ -28,18 +28,20 @@ class RetailcrmCatalog
|
||||
}
|
||||
|
||||
$currencies = Currency::getCurrencies();
|
||||
|
||||
$link = new Link();
|
||||
$types = Category::getCategories($id_lang, true, false);
|
||||
foreach ($types AS $category) {
|
||||
|
||||
foreach ($types as $category) {
|
||||
$picture = $link->getCatImageLink($category['link_rewrite'], $category['id_category'], 'category_default');
|
||||
|
||||
$categories[] = array(
|
||||
'id' => $category['id_category'],
|
||||
'parentId' => $category['id_parent'],
|
||||
'name' => $category['name']
|
||||
'name' => $category['name'],
|
||||
'picture' => $picture ? $protocol . $picture : ''
|
||||
);
|
||||
}
|
||||
|
||||
$link = new Link();
|
||||
|
||||
$products = Product::getProducts($id_lang, 0, 0, 'name', 'asc');
|
||||
|
||||
foreach ($products AS $product) {
|
||||
@ -59,6 +61,7 @@ class RetailcrmCatalog
|
||||
}
|
||||
|
||||
$version = substr(_PS_VERSION_, 0, 3);
|
||||
|
||||
if ($version == "1.3") {
|
||||
$available_for_order = $product['active'] && $product['quantity'];
|
||||
} else {
|
||||
@ -114,28 +117,35 @@ class RetailcrmCatalog
|
||||
|
||||
$offers = Product::getProductAttributesIds($product['id_product']);
|
||||
|
||||
if(!empty($offers)) {
|
||||
if (!empty($offers)) {
|
||||
foreach($offers as $offer) {
|
||||
|
||||
$combinations = $productForCombination->getAttributeCombinationsById($offer['id_product_attribute' ], $id_lang);
|
||||
if (!empty($combinations)) {
|
||||
|
||||
if (!empty($combinations)) {
|
||||
foreach ($combinations as $combination) {
|
||||
$arSet = array(
|
||||
'group_name' => $combination['group_name'],
|
||||
'attribute' => $combination['attribute_name'],
|
||||
);
|
||||
$arComb[] = $arSet;
|
||||
$arSet = array(
|
||||
'group_name' => $combination['group_name'],
|
||||
'attribute' => $combination['attribute_name'],
|
||||
);
|
||||
|
||||
$arComb[] = $arSet;
|
||||
}
|
||||
}
|
||||
|
||||
$pictures = array();
|
||||
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
|
||||
foreach($covers as $cover) {
|
||||
|
||||
foreach ($covers as $cover) {
|
||||
$picture = $protocol . $link->getImageLink($product['link_rewrite'], $product['id_product'] . '-' . $cover['id_image'], 'large_default');
|
||||
$pictures[] = $picture;
|
||||
}
|
||||
|
||||
if (!$pictures) {
|
||||
$image = Image::getCover($product['id_product']);
|
||||
$picture = $protocol . $link->getImageLink($product['link_rewrite'], $image['id_image'], 'large_default');
|
||||
$pictures[] = $picture;
|
||||
}
|
||||
|
||||
if ($version == "1.3") {
|
||||
$quantity = $product['quantity'];
|
||||
} else {
|
||||
|
@ -50,10 +50,9 @@ class RetailcrmHistory
|
||||
$customer->email = $customerHistory['email'];
|
||||
}
|
||||
|
||||
if (self::loadInCMS($customer, 'update') === false){
|
||||
if (self::loadInCMS($customer, 'update') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
$customer = new Customer();
|
||||
|
||||
@ -112,7 +111,6 @@ class RetailcrmHistory
|
||||
if (self::loadInCMS($customerAddress, 'add') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$customerFix[] = array(
|
||||
@ -466,7 +464,6 @@ class RetailcrmHistory
|
||||
$carrier->id_carrier = $deliveryType;
|
||||
$carrier->shipping_cost_tax_excl = $order['delivery']['cost'];
|
||||
$carrier->shipping_cost_tax_incl = $order['delivery']['cost'];
|
||||
$carrier->date_add = isset($order['delivery']['date']) ? $order['delivery']['date'] : '';
|
||||
$carrier->add(false, false);
|
||||
|
||||
/*
|
||||
@ -479,7 +476,6 @@ class RetailcrmHistory
|
||||
*/
|
||||
$orderDetail = new OrderDetail();
|
||||
$orderDetail->createList($newOrder, $cart, $newOrder->current_state, $product_list);
|
||||
$orderDetail->save();
|
||||
|
||||
if (!empty($customerFix)) {
|
||||
self::$api->customersFixExternalIds($customerFix);
|
||||
@ -705,6 +701,7 @@ class RetailcrmHistory
|
||||
$productName = htmlspecialchars(strip_tags($product->name));
|
||||
$productPrice = $product->price;
|
||||
}
|
||||
|
||||
// discount
|
||||
if ((isset($newItem['discount']) && $newItem['discount'])
|
||||
|| (isset($newItem['discountPercent']) && $newItem['discountPercent'])
|
||||
@ -715,6 +712,7 @@ class RetailcrmHistory
|
||||
$productPrice = $productPrice - ($prodPrice / 100 * $newItem['discountPercent']);
|
||||
$ItemDiscount = true;
|
||||
}
|
||||
|
||||
$orderDetail = new OrderDetail();
|
||||
$orderDetail->id_order = $orderToUpdate->id;
|
||||
$orderDetail->id_order_invoice = $orderToUpdate->invoice_number;
|
||||
@ -737,6 +735,12 @@ class RetailcrmHistory
|
||||
}
|
||||
}
|
||||
|
||||
$infoOrd = self::$api->ordersGet($order['externalId']);
|
||||
$infoOrder = $infoOrd->order;
|
||||
$totalPaid = $infoOrder['totalSumm'];
|
||||
$orderToUpdate->total_paid = $totalPaid;
|
||||
$orderToUpdate->update();
|
||||
|
||||
/*
|
||||
* Fix prices & discounts
|
||||
* Discounts only for whole order
|
||||
@ -747,17 +751,16 @@ class RetailcrmHistory
|
||||
|| isset($order['discountTotal'])
|
||||
|| $ItemDiscount
|
||||
) {
|
||||
$infoOrd = self::$api->ordersGet($order['externalId']);
|
||||
$infoOrder = $infoOrd->order;
|
||||
$orderTotalProducts = $infoOrder['summ'];
|
||||
$totalPaid = $infoOrder['totalSumm'];
|
||||
$deliveryCost = $infoOrder['delivery']['cost'];
|
||||
$totalDiscount = $deliveryCost + $orderTotalProducts - $totalPaid;
|
||||
$orderCartRules = $orderToUpdate->getCartRules();
|
||||
|
||||
foreach ($orderCartRules as $valCartRules) {
|
||||
$order_cart_rule = new OrderCartRule($valCartRules['id_order_cart_rule']);
|
||||
$order_cart_rule->delete();
|
||||
}
|
||||
|
||||
$orderToUpdate->total_discounts = $totalDiscount;
|
||||
$orderToUpdate->total_discounts_tax_incl = $totalDiscount;
|
||||
$orderToUpdate->total_discounts_tax_excl = $totalDiscount;
|
||||
|
@ -49,7 +49,7 @@ class RetailcrmIcml
|
||||
';
|
||||
|
||||
$xml = new SimpleXMLElement(
|
||||
$string, LIBXML_NOENT | LIBXML_NOCDATA | LIBXML_COMPACT | LIBXML_PARSEHUGE
|
||||
$string, LIBXML_NOENT | LIBXML_NOCDATA | LIBXML_COMPACT | LIBXML_PARSEHUGE
|
||||
);
|
||||
|
||||
$this->dd = new DOMDocument();
|
||||
@ -58,9 +58,9 @@ class RetailcrmIcml
|
||||
$this->dd->loadXML($xml->asXML());
|
||||
|
||||
$this->eCategories = $this->dd
|
||||
->getElementsByTagName('categories')->item(0);
|
||||
->getElementsByTagName('categories')->item(0);
|
||||
$this->eOffers = $this->dd
|
||||
->getElementsByTagName('offers')->item(0);
|
||||
->getElementsByTagName('offers')->item(0);
|
||||
|
||||
$this->addCategories($categories);
|
||||
$this->addOffers($offers);
|
||||
@ -73,12 +73,17 @@ class RetailcrmIcml
|
||||
{
|
||||
foreach ($categories as $category) {
|
||||
$e = $this->eCategories->appendChild(
|
||||
$this->dd->createElement(
|
||||
'category', $category['name']
|
||||
)
|
||||
$this->dd->createElement(
|
||||
'category'
|
||||
)
|
||||
);
|
||||
|
||||
$e->setAttribute('id', $category['id']);
|
||||
$e->appendChild($this->dd->createElement('name', $category['name']));
|
||||
|
||||
if ($category['picture']) {
|
||||
$e->appendChild($this->dd->createElement('picture', $category['picture']));
|
||||
}
|
||||
|
||||
if ($category['parentId'] > 0) {
|
||||
$e->setAttribute('parentId', $category['parentId']);
|
||||
@ -91,7 +96,7 @@ class RetailcrmIcml
|
||||
foreach ($offers as $offer) {
|
||||
|
||||
$e = $this->eOffers->appendChild(
|
||||
$this->dd->createElement('offer')
|
||||
$this->dd->createElement('offer')
|
||||
);
|
||||
|
||||
$e->setAttribute('id', $offer['id']);
|
||||
@ -105,14 +110,14 @@ class RetailcrmIcml
|
||||
|
||||
foreach ($offer['categoryId'] as $categoryId) {
|
||||
$e->appendChild(
|
||||
$this->dd->createElement('categoryId', $categoryId)
|
||||
$this->dd->createElement('categoryId', $categoryId)
|
||||
);
|
||||
}
|
||||
|
||||
$offerKeys = array_keys($offer);
|
||||
|
||||
foreach ($offerKeys as $key) {
|
||||
if($offer[$key] == null) continue;
|
||||
if ($offer[$key] == null) continue;
|
||||
|
||||
if (in_array($key, $this->properties)) {
|
||||
if(is_array($offer[$key])) {
|
||||
@ -137,7 +142,7 @@ class RetailcrmIcml
|
||||
$param->setAttribute('code', $key);
|
||||
$param->setAttribute('name', $this->params[$key]);
|
||||
$param->appendChild(
|
||||
$this->dd->createTextNode($offer[$key])
|
||||
$this->dd->createTextNode($offer[$key])
|
||||
);
|
||||
$e->appendChild($param);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ abstract class RetailcrmTestCase extends \PHPUnit\Framework\TestCase
|
||||
parent::setUp();
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>')) {
|
||||
$contextMocker = new \Tests\Unit\ContextMocker();
|
||||
$contextMocker = new \LegacyTests\Unit\ContextMocker();
|
||||
$this->contextMock = $contextMocker->mockContext();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../PrestaShop/tests/bootstrap.php';
|
||||
if (\file_exists(__DIR__ . '/../../../PrestaShop/tests-legacy')) {
|
||||
require_once __DIR__ . '/../../../PrestaShop/tests-legacy/bootstrap.php';
|
||||
} else {
|
||||
require_once __DIR__ . '/../../../PrestaShop/tests/bootstrap.php';
|
||||
}
|
||||
|
||||
require_once dirname(__DIR__) . '../../../PrestaShop/config/config.inc.php';
|
||||
require_once dirname(__DIR__) . '../../../PrestaShop/config/defines_uri.inc.php';
|
||||
require_once dirname(__DIR__) . '../../retailcrm/bootstrap.php';
|
||||
|
Loading…
x
Reference in New Issue
Block a user