minor fixes & readme
This commit is contained in:
parent
f370e6d085
commit
3ce9c12d88
13
README.md
13
README.md
@ -1,2 +1,11 @@
|
|||||||
# Magento RetailCRM module
|
Magento module
|
||||||
Модуль Magento интеграции с RetailCRM
|
==============
|
||||||
|
|
||||||
|
Magento module for interaction with [RetailCRM](http://www.retailcrm.ru) through [REST API](http://retailcrm.ru/docs/Разработчики).
|
||||||
|
|
||||||
|
Module allows:
|
||||||
|
|
||||||
|
* Exchange the orders with retailCRM
|
||||||
|
* Configure relations between dictionaries of RetailCRM and Magento (statuses, payments, delivery types and etc)
|
||||||
|
* Generate [ICML](http://docs.retailcrm.ru/index.php?n=Разработчики.ФорматICML) (Intaro Markup Language) for catalog loading by RetailCRM
|
||||||
|
|
||||||
|
@ -27,12 +27,17 @@ class Retailcrm_Retailcrm_Model_Exchange
|
|||||||
*/
|
*/
|
||||||
public function ordersCreate($order)
|
public function ordersCreate($order)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->_config = Mage::getStoreConfig('retailcrm', $order->getStoreId());
|
$this->_config = Mage::getStoreConfig('retailcrm', $order->getStoreId());
|
||||||
|
|
||||||
$statuses = array_flip(array_filter($this->_config['status']));
|
$statuses = array_flip(array_filter($this->_config['status']));
|
||||||
$payments = array_filter($this->_config['payment']);
|
$payments = array_filter($this->_config['payment']);
|
||||||
$shippings = array_filter($this->_config['shipping']);
|
$shippings = array_filter($this->_config['shipping']);
|
||||||
|
|
||||||
|
$shipment = $order->getShippingMethod();
|
||||||
|
$shipment = explode('_', $shipment);
|
||||||
|
$shipment = $shipment[0];
|
||||||
|
|
||||||
$address = $order->getShippingAddress()->getData();
|
$address = $order->getShippingAddress()->getData();
|
||||||
|
|
||||||
$orderItems = $order->getAllItems();
|
$orderItems = $order->getAllItems();
|
||||||
@ -48,7 +53,7 @@ class Retailcrm_Retailcrm_Model_Exchange
|
|||||||
}
|
}
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
|
|
||||||
foreach ($simpleItems as $item) {
|
foreach ($simpleItems as $item) {
|
||||||
|
|
||||||
$product = array(
|
$product = array(
|
||||||
@ -56,29 +61,29 @@ class Retailcrm_Retailcrm_Model_Exchange
|
|||||||
'productName' => $item->getName(),
|
'productName' => $item->getName(),
|
||||||
'quantity' => (int) $item->getData('qty_ordered')
|
'quantity' => (int) $item->getData('qty_ordered')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($item->getData('parent_item_id')) {
|
if ($item->getData('parent_item_id')) {
|
||||||
$product['initialPrice'] = $confItems[$item->getData('parent_item_id')]->getPrice();
|
$product['initialPrice'] = $confItems[$item->getData('parent_item_id')]->getPrice();
|
||||||
|
|
||||||
/*if ($confItems[$item->getData('parent_item_id')]->getDiscountAmount() > 0) {
|
/*if ($confItems[$item->getData('parent_item_id')]->getDiscountAmount() > 0) {
|
||||||
$product['discount'] = $confItems[$item->getData('parent_item_id')]->getDiscountAmount();
|
$product['discount'] = $confItems[$item->getData('parent_item_id')]->getDiscountAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($confItems[$item->getData('parent_item_id')]->getDiscountPercent() > 0) {
|
if ($confItems[$item->getData('parent_item_id')]->getDiscountPercent() > 0) {
|
||||||
$product['discountPercent'] = $confItems[$item->getData('parent_item_id')]->getDiscountPercent();
|
$product['discountPercent'] = $confItems[$item->getData('parent_item_id')]->getDiscountPercent();
|
||||||
}*/
|
}*/
|
||||||
} else {
|
} else {
|
||||||
$product['initialPrice'] = $item->getPrice();
|
$product['initialPrice'] = $item->getPrice();
|
||||||
|
|
||||||
/*if ($item->getDiscountAmount() > 0) {
|
/*if ($item->getDiscountAmount() > 0) {
|
||||||
$product['discount'] = $item->getDiscountAmount();
|
$product['discount'] = $item->getDiscountAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getDiscountPercent() > 0) {
|
if ($item->getDiscountPercent() > 0) {
|
||||||
$product['discountPercent'] = $item->getDiscountPercent();
|
$product['discountPercent'] = $item->getDiscountPercent();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = $product;
|
$items[] = $product;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +100,7 @@ class Retailcrm_Retailcrm_Model_Exchange
|
|||||||
$customerId = $this->setCustomerId($customer);
|
$customerId = $this->setCustomerId($customer);
|
||||||
unset($customer);
|
unset($customer);
|
||||||
|
|
||||||
|
$comment = $order->getStatusHistoryCollection()->getFirstItem();
|
||||||
$preparedOrder = array(
|
$preparedOrder = array(
|
||||||
'site' => $order->getStore()->getCode(),
|
'site' => $order->getStore()->getCode(),
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
@ -110,8 +116,9 @@ class Retailcrm_Retailcrm_Model_Exchange
|
|||||||
'status' => $statuses[$order->getStatus()],
|
'status' => $statuses[$order->getStatus()],
|
||||||
'discount' => abs($order->getDiscountAmount()),
|
'discount' => abs($order->getDiscountAmount()),
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
|
'customerComment' => $comment->getComment(),
|
||||||
'delivery' => array(
|
'delivery' => array(
|
||||||
'code' => $shippings[$order->getShippingMethod()],
|
'code' => $shippings[$shipment],
|
||||||
'cost' => $order->getShippingAmount(),
|
'cost' => $order->getShippingAmount(),
|
||||||
'address' => array(
|
'address' => array(
|
||||||
'index' => $address['postcode'],
|
'index' => $address['postcode'],
|
||||||
|
Loading…
Reference in New Issue
Block a user