cleanup, icml improvements, state-status mapping settings
This commit is contained in:
parent
ba08ed414a
commit
adcdd015b9
@ -1,2 +1,2 @@
|
||||
# module-magento
|
||||
Модуль Magento для интеграции с retailCRM через REST API
|
||||
# Magento RetailCRM module
|
||||
Модуль Magento интеграции с RetailCRM
|
||||
|
@ -10,6 +10,7 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Base exten
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_apiUrl = Mage::getStoreConfig('retailcrm/general/api_url');
|
||||
$this->_apiKey = Mage::getStoreConfig('retailcrm/general/api_key');
|
||||
|
||||
|
@ -4,26 +4,43 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
public function render(Varien_Data_Form_Element_Abstract $element)
|
||||
{
|
||||
$html = $this->_getHeaderHtml($element);
|
||||
if(!empty($this->_apiUrl) && !empty($this->_apiKey) && $this->_isCredentialCorrect) {
|
||||
$warn = '
|
||||
<div style="margin-left: 15px;">
|
||||
<b><i>Please check your API Url & API Key</i></b>
|
||||
</div>
|
||||
';
|
||||
|
||||
$client = Mage::getModel(
|
||||
'retailcrm/ApiClient',
|
||||
array('url' => $this->_apiUrl, 'key' => $this->_apiKey, 'site' => null)
|
||||
if(!empty($this->_apiUrl) && !empty($this->_apiKey) && $this->_isCredentialCorrect) {
|
||||
$orderEntity = Mage::getModel('sales/order');
|
||||
$reflection = new ReflectionClass($orderEntity);
|
||||
$constants = $reflection->getConstants();
|
||||
$values = array();
|
||||
|
||||
foreach ($constants as $key => $value)
|
||||
{
|
||||
if (preg_match("/state_/i", $key)) {
|
||||
$label = implode(
|
||||
' ',
|
||||
$arr = array_map(
|
||||
function($word) {
|
||||
return ucfirst($word);
|
||||
},
|
||||
explode('_', $value)
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$statuses = $client->statusesList();
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log($e->getMessage());
|
||||
$values[] = array('code' => $value, 'name' => $label);
|
||||
}
|
||||
}
|
||||
|
||||
if ($statuses->isSuccessful() && !empty($statuses)) {
|
||||
foreach ($statuses['statuses'] as $group) {
|
||||
if (!empty($values)) {
|
||||
foreach ($values as $group) {
|
||||
$html.= $this->_getFieldHtml($element, $group);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$html .= '<div style="margin-left: 15px;"><b><i>Please check your API Url & API Key</i></b></div>';
|
||||
$html .= $warn;
|
||||
}
|
||||
|
||||
$html .= $this->_getFooterHtml($element);
|
||||
@ -34,7 +51,9 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
protected function _getFieldRenderer()
|
||||
{
|
||||
if (empty($this->_fieldRenderer)) {
|
||||
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
|
||||
$this->_fieldRenderer = Mage::getBlockSingleton(
|
||||
'adminhtml/system_config_form_field'
|
||||
);
|
||||
}
|
||||
return $this->_fieldRenderer;
|
||||
}
|
||||
@ -44,12 +63,35 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
*/
|
||||
protected function _getValues()
|
||||
{
|
||||
$values = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
||||
$client = Mage::getModel(
|
||||
'retailcrm/ApiClient',
|
||||
array(
|
||||
'url' => $this->_apiUrl,
|
||||
'key' => $this->_apiKey,
|
||||
'site' => null
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$statuses = $client->statusesList();
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log($e->getMessage());
|
||||
}
|
||||
|
||||
if (empty($this->_values)) {
|
||||
$this->_values[] = array('label'=>Mage::helper('adminhtml')->__('===Select status==='), 'value'=>'');
|
||||
foreach ($values as $value) {
|
||||
$this->_values[] = array('label'=>Mage::helper('adminhtml')->__($value['label']), 'value'=>$value['status']);
|
||||
$this->_values[] = array(
|
||||
'label' => Mage::helper('adminhtml')
|
||||
->__('===Select status==='),
|
||||
'value' => ''
|
||||
);
|
||||
if ($statuses->isSuccessful() && !empty($statuses)) {
|
||||
foreach ($statuses['statuses'] as $status) {
|
||||
$this->_values[] = array(
|
||||
'label' => Mage::helper('adminhtml')
|
||||
->__($status['name']),
|
||||
'value' => $status['code']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +108,8 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
$data = $configData[$path];
|
||||
$inherit = false;
|
||||
} else {
|
||||
$data = (int)(string)$this->getForm()->getConfigRoot()->descend($path);
|
||||
$data = (int) (string) $this->getForm()
|
||||
->getConfigRoot()->descend($path);
|
||||
$inherit = true;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,15 @@ class Retailcrm_Retailcrm_Model_Exchange
|
||||
'country' => $address['country_id'],
|
||||
'street' => $address['street'],
|
||||
'region' => $address['region'],
|
||||
|
||||
'text' => implode(
|
||||
','
|
||||
array(
|
||||
$address['postcode'],
|
||||
$address['country_id'],
|
||||
$address['city'],
|
||||
$address['street']
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -210,250 +218,4 @@ class Retailcrm_Retailcrm_Model_Exchange
|
||||
? array('success' => true, 'result' => $result)
|
||||
: array('success' => false, 'result' => $searchResult[0]['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @internal param mixed $order
|
||||
*
|
||||
*/
|
||||
/*public function orderEdit($order)
|
||||
{
|
||||
$this->_config = Mage::getStoreConfig('retailcrm', $order->getStoreId());
|
||||
|
||||
$statuses = array_flip(array_filter($this->_config['status']));
|
||||
$paymentsStatuses = array_flip(array_filter($this->_config['paymentstatuses']));
|
||||
$payments = array_filter($this->_config['payment']);
|
||||
$shippings = array_filter($this->_config['shipping']);
|
||||
|
||||
$address = $order->getShippingAddress()->getData();
|
||||
|
||||
$orderItems = $order->getItemsCollection();
|
||||
$items = array();
|
||||
|
||||
foreach ($orderItems as $item){
|
||||
$items[] = array(
|
||||
'productId' => $item->product_id,
|
||||
'initialPrice' => $item->getPrice(),
|
||||
'taxPrice' => $item->getPriceInclTax(),
|
||||
'productName' => $item->getName(),
|
||||
'quantity' => (int) $item->getData('qty_ordered')
|
||||
);
|
||||
}
|
||||
|
||||
$preparedOrder = array(
|
||||
'site' => $order->getStore()->getCode(),
|
||||
'externalId' => $order->getId(),
|
||||
'number' => $order->getRealOrderId(),
|
||||
'createdAt' => $order->getCreatedAt(),
|
||||
'customerId' => ($order->getCustomerIsGuest() == 0) ? $order->getCustomerId() : 'g' . $order->getRealOrderId(),
|
||||
'lastName' => $order->getCustomerLastname(),
|
||||
'firstName' => $order->getCustomerFirstname(),
|
||||
'patronymic' => $order->getCustomerMiddlename(),
|
||||
'email' => $order->getCustomerEmail(),
|
||||
'phone' => $address['telephone'],
|
||||
'paymentType' => $payments[$order->getPayment()->getMethodInstance()->getCode()],
|
||||
'paymentStatus' => $paymentsStatuses[$order->getStatus()],
|
||||
'status' => $statuses[$order->getStatus()],
|
||||
'discount' => abs($order->getDiscountAmount()),
|
||||
'items' => $items,
|
||||
'delivery' => array(
|
||||
'code' => $shippings[$order->getShippingMethod()],
|
||||
'cost' => $order->getShippingAmount(),
|
||||
'address' => array(
|
||||
'index' => $address['postcode'],
|
||||
'city' => $address['city'],
|
||||
'country' => $address['country_id'],
|
||||
'street' => $address['street'],
|
||||
'region' => $address['region'],
|
||||
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$this->_api->ordersEdit($preparedOrder);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log($e->getMessage());
|
||||
}
|
||||
}*/
|
||||
|
||||
/*public function processOrders($orders, $nocheck = false)
|
||||
{
|
||||
|
||||
if (!$nocheck) {
|
||||
foreach ($orders as $idx => $order) {
|
||||
$customer = array();
|
||||
$customer['phones'][]['number'] = $order['phone'];
|
||||
$customer['externalId'] = $order['customerId'];
|
||||
$customer['firstName'] = $order['firstName'];
|
||||
$customer['lastName'] = $order['lastName'];
|
||||
$customer['patronymic'] = $order['patronymic'];
|
||||
$customer['address'] = $order['delivery']['address'];
|
||||
|
||||
if (isset($order['email'])) {
|
||||
$customer['email'] = $order['email'];
|
||||
}
|
||||
|
||||
$checkResult = $this->checkCustomers($customer);
|
||||
|
||||
if ($checkResult === false) {
|
||||
unset($orders[$idx]["customerId"]);
|
||||
} else {
|
||||
$orders[$idx]["customerId"] = $checkResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$splitOrders = array_chunk($orders, 50);
|
||||
|
||||
foreach($splitOrders as $orders) {
|
||||
try {
|
||||
$response = $this->_api->ordersUpload($orders);
|
||||
time_nanosleep(0, 250000000);
|
||||
if (!$response->isSuccessful()) {
|
||||
Mage::log('RestApi::ordersUpload::API: ' . $response->getErrorMsg());
|
||||
if (isset($response['errors'])) {
|
||||
foreach ($response['errors'] as $error) {
|
||||
Mage::log('RestApi::ordersUpload::API: ' . $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::ordersUpload::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/*public function orderHistory()
|
||||
{
|
||||
try {
|
||||
$orders = $this->_api->ordersHistory(new DateTime($this->getDate($this->historyLog)));
|
||||
Mage::log($orders->getGeneratedAt(), null, 'history.log');
|
||||
return $orders['orders'];
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::orderHistory::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
/*public function orderFixExternalIds($data)
|
||||
{
|
||||
try {
|
||||
$this->_api->ordersFixExternalIds($data);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::orderFixExternalIds::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
/*public function customerFixExternalIds($data)
|
||||
{
|
||||
try {
|
||||
$this->_api->customersFixExternalIds($data);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::customerFixExternalIds::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Export References to CRM
|
||||
*
|
||||
* @param array $deliveries deliveries data
|
||||
* @param array $payments payments data
|
||||
* @param array $statuses statuses data
|
||||
*
|
||||
*/
|
||||
/*public function processReference($deliveries = null, $payments = null, $statuses = null)
|
||||
{
|
||||
if ($deliveries != null) {
|
||||
$this->processDeliveries($deliveries);
|
||||
}
|
||||
|
||||
if ($payments != null) {
|
||||
$this->processPayments($payments);
|
||||
}
|
||||
|
||||
if ($statuses != null) {
|
||||
$this->processStatuses($statuses);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Export deliveries
|
||||
*
|
||||
* @param array $deliveries
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
/*protected function processDeliveries($deliveries)
|
||||
{
|
||||
foreach ($deliveries as $delivery) {
|
||||
try {
|
||||
$this->_api->deliveryTypesEdit($delivery);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::deliveryEdit::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Export payments
|
||||
*
|
||||
* @param array $payments
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
/*protected function processPayments($payments)
|
||||
{
|
||||
foreach ($payments as $payment) {
|
||||
try {
|
||||
$this->_api->paymentTypesEdit($payment);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::paymentEdit::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Export statuses
|
||||
*
|
||||
* @param array $statuses
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
/*protected function processStatuses($statuses)
|
||||
{
|
||||
foreach ($statuses as $status) {
|
||||
try {
|
||||
$this->_api->statusesEdit($status);
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log('RestApi::statusEdit::Curl: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
|
@ -21,22 +21,28 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
</yml_catalog>
|
||||
';
|
||||
|
||||
$xml = new SimpleXMLElement($string, LIBXML_NOENT |LIBXML_NOCDATA | LIBXML_COMPACT | LIBXML_PARSEHUGE);
|
||||
$xml = new SimpleXMLElement(
|
||||
$string,
|
||||
LIBXML_NOENT |LIBXML_NOCDATA | LIBXML_COMPACT | LIBXML_PARSEHUGE
|
||||
);
|
||||
|
||||
$this->_dd = new DOMDocument();
|
||||
$this->_dd->preserveWhiteSpace = false;
|
||||
$this->_dd->formatOutput = true;
|
||||
$this->_dd->loadXML($xml->asXML());
|
||||
|
||||
$this->_eCategories = $this->_dd->getElementsByTagName('categories')->item(0);
|
||||
$this->_eOffers = $this->_dd->getElementsByTagName('offers')->item(0);
|
||||
$this->_eCategories = $this->_dd->
|
||||
getElementsByTagName('categories')->item(0);
|
||||
$this->_eOffers = $this->_dd
|
||||
->getElementsByTagName('offers')->item(0);
|
||||
|
||||
$this->addCategories();
|
||||
$this->addOffers();
|
||||
|
||||
$this->_dd->saveXML();
|
||||
$baseDir = Mage::getBaseDir();
|
||||
$this->_dd->save($baseDir . DS . 'retailcrm_' . Mage::app()->getStore($shop)->getCode() . '.xml');
|
||||
$shopCode = Mage::app()->getStore($shop)->getCode();
|
||||
$this->_dd->save($baseDir . DS . 'retailcrm_' . $shopCode . '.xml');
|
||||
}
|
||||
|
||||
private function addCategories()
|
||||
@ -52,6 +58,7 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
{
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if ($id > 1) {
|
||||
$category = Mage::getModel('catalog/category');
|
||||
$category->load($id);
|
||||
$categoryData = array(
|
||||
@ -62,13 +69,16 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
array_push($categories, $categoryData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($categories as $category) {
|
||||
$e = $this->_eCategories->appendChild($this->_dd->createElement('category'));
|
||||
$e = $this->_eCategories->appendChild(
|
||||
$this->_dd->createElement('category')
|
||||
);
|
||||
$e->appendChild($this->_dd->createTextNode($category['name']));
|
||||
$e->setAttribute('id', $category['id']);
|
||||
|
||||
if ($category['parentId'] > 0) {
|
||||
if ($category['parentId'] > 1) {
|
||||
$e->setAttribute('parentId', $category['parentId']);
|
||||
}
|
||||
}
|
||||
@ -78,6 +88,7 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
{
|
||||
$offers = array();
|
||||
$helper = Mage::helper('retailcrm');
|
||||
$picUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
||||
|
||||
$collection = Mage::getModel('catalog/product')
|
||||
->getCollection()
|
||||
@ -89,17 +100,26 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
$offer = array();
|
||||
$offer['id'] = $product->getId();
|
||||
$offer['productId'] = $product->getId();
|
||||
$offer['productActivity'] = $product->isAvailable() ? 'Y' : 'N';
|
||||
$offer['name'] = $product->getName();
|
||||
$offer['productName'] = $product->getName();
|
||||
$offer['initialPrice'] = (float) $product->getPrice();
|
||||
$offer['url'] = $helper->rewrittenProductUrl($product->getId(), $product->getCategoryId(), $this->_shop);
|
||||
$offer['picture'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product'.$product->getImage();
|
||||
$offer['quantity'] = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
||||
|
||||
$offer['url'] = $helper->rewrittenProductUrl(
|
||||
$product->getId(), $product->getCategoryId(), $this->_shop
|
||||
);
|
||||
|
||||
$offer['picture'] = $picUrl.'catalog/product'.$product->getImage();
|
||||
|
||||
$offer['quantity'] = Mage::getModel('cataloginventory/stock_item')
|
||||
->loadByProduct($product)->getQty();
|
||||
|
||||
foreach ($product->getCategoryIds() as $category_id) {
|
||||
$offer['categoryId'][] = $category_id;
|
||||
}
|
||||
|
||||
$offer['vendor'] = $product->getAttributeText('manufacturer');
|
||||
|
||||
$offer['article'] = $product->getSku();
|
||||
$offer['weight'] = $product->getWeight();
|
||||
|
||||
@ -109,71 +129,100 @@ class Retailcrm_Retailcrm_Model_Icml
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
|
||||
$e = $this->_eOffers->appendChild($this->_dd->createElement('offer'));
|
||||
$e = $this->_eOffers->appendChild(
|
||||
$this->_dd->createElement('offer')
|
||||
);
|
||||
|
||||
$e->setAttribute('id', $offer['id']);
|
||||
$e->setAttribute('productId', $offer['productId']);
|
||||
|
||||
if (isset($offer['quantity'] ) && $offer['quantity'] != '') {
|
||||
$e->setAttribute('quantity', (int)$offer['quantity']);
|
||||
if (!empty($offer['quantity'])) {
|
||||
$e->setAttribute('quantity', (int) $offer['quantity']);
|
||||
} else {
|
||||
$e->setAttribute('quantity', 0);
|
||||
}
|
||||
|
||||
if (!empty($offer['categoryId'])) {
|
||||
foreach ($offer['categoryId'] as $categoryId) {
|
||||
$e->appendChild($this->_dd->createElement('categoryId', $categoryId));
|
||||
$e->appendChild(
|
||||
$this->_dd->createElement('categoryId')
|
||||
)->appendChild(
|
||||
$this->_dd->createTextNode($categoryId)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$e->appendChild($this->_dd->createElement('categoryId', 1));
|
||||
}
|
||||
|
||||
$e->appendChild($this->_dd->createElement('name'))->appendChild($this->_dd->createTextNode($offer['name']));
|
||||
$e->appendChild($this->_dd->createElement('productName'))->appendChild($this->_dd->createTextNode($offer['name']));
|
||||
$e->appendChild($this->_dd->createElement('price', $offer['initialPrice']));
|
||||
$e->appendChild($this->_dd->createElement('productActivity'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['productActivity'])
|
||||
);
|
||||
|
||||
if (isset($offer['purchasePrice'] ) && $offer['purchasePrice'] != '') {
|
||||
$e->appendChild($this->_dd->createElement('purchasePrice'))->appendChild($this->_dd->createTextNode($offer['purchasePrice']));
|
||||
$e->appendChild($this->_dd->createElement('name'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['name'])
|
||||
);
|
||||
|
||||
$e->appendChild($this->_dd->createElement('productName'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['productName'])
|
||||
);
|
||||
|
||||
$e->appendChild($this->_dd->createElement('price'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['initialPrice'])
|
||||
);
|
||||
|
||||
if (!empty($offer['purchasePrice'])) {
|
||||
$e->appendChild($this->_dd->createElement('purchasePrice'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['purchasePrice']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($offer['vendor'] ) && $offer['vendor'] != '') {
|
||||
$e->appendChild($this->_dd->createElement('vendor'))->appendChild($this->_dd->createTextNode($offer['vendor']));
|
||||
if (!empty($offer['picture'])) {
|
||||
$e->appendChild($this->_dd->createElement('picture'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['picture'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($offer['picture'] ) && $offer['picture'] != '') {
|
||||
$e->appendChild($this->_dd->createElement('picture', $offer['picture']));
|
||||
if (!empty($offer['url'])) {
|
||||
$e->appendChild($this->_dd->createElement('url'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['url']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($offer['url'] ) && $offer['url'] != '') {
|
||||
$e->appendChild($this->_dd->createElement('url'))->appendChild($this->_dd->createTextNode($offer['url']));
|
||||
if (!empty($offer['vendor'])) {
|
||||
$e->appendChild($this->_dd->createElement('vendor'))
|
||||
->appendChild(
|
||||
$this->_dd->createTextNode($offer['vendor']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($offer['xmlId'] ) && $offer['xmlId'] != '') {
|
||||
$e->appendChild($this->_dd->createElement('xmlId'))->appendChild($this->_dd->createTextNode($offer['xmlId']));
|
||||
}
|
||||
|
||||
if (isset($offer['article'] ) && $offer['article'] != '') {
|
||||
if (!empty($offer['article'] )) {
|
||||
$sku = $this->_dd->createElement('param');
|
||||
$sku->setAttribute('name', 'article');
|
||||
$sku->appendChild($this->_dd->createTextNode($offer['article']));
|
||||
$sku->setAttribute('code', 'Article');
|
||||
$sku->appendChild(
|
||||
$this->_dd->createTextNode($offer['article'])
|
||||
);
|
||||
$e->appendChild($sku);
|
||||
}
|
||||
|
||||
if (isset($offer['size'] ) && $offer['size'] != '') {
|
||||
$size = $this->_dd->createElement('param');
|
||||
$size->setAttribute('name', 'size');
|
||||
$size->appendChild($this->_dd->createTextNode($offer['size']));
|
||||
$e->appendChild($size);
|
||||
}
|
||||
|
||||
if (isset($offer['color'] ) && $offer['color'] != '') {
|
||||
$color = $this->_dd->createElement('param');
|
||||
$color->setAttribute('name', 'color');
|
||||
$color->appendChild($this->_dd->createTextNode($offer['color']));
|
||||
$e->appendChild($color);
|
||||
}
|
||||
|
||||
if (isset($offer['weight'] ) && $offer['weight'] != '') {
|
||||
if (!empty($offer['weight'] )) {
|
||||
$weight = $this->_dd->createElement('param');
|
||||
$weight->setAttribute('name', 'weight');
|
||||
$weight->appendChild($this->_dd->createTextNode($offer['weight']));
|
||||
$weight->setAttribute('code', 'Weight');
|
||||
$weight->appendChild(
|
||||
$this->_dd->createTextNode($offer['weight'])
|
||||
);
|
||||
$e->appendChild($weight);
|
||||
}
|
||||
}
|
||||
|
@ -20,27 +20,6 @@ class Retailcrm_Retailcrm_Model_Observer
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event after order updated
|
||||
*
|
||||
* @param Varien_Event_Observer $observer
|
||||
* @return bool
|
||||
*/
|
||||
public function orderUpdate(Varien_Event_Observer $observer)
|
||||
{
|
||||
$order = $observer->getEvent()->getOrder();
|
||||
|
||||
if($order->getExportProcessed()){ //check if flag is already set for prevent triggering twice.
|
||||
return;
|
||||
}
|
||||
|
||||
Mage::getModel('retailcrm/exchange')->orderEdit($order);
|
||||
|
||||
$order->setExportProcessed(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function exportCatalog()
|
||||
{
|
||||
foreach (Mage::app()->getWebsites() as $website) {
|
||||
|
@ -1,20 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright 2015 RetailCRM.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 RetailDriver LLC
|
||||
|
||||
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.
|
||||
-->
|
||||
<config>
|
||||
<modules>
|
||||
@ -48,15 +54,6 @@
|
||||
</retailcrm_retailcrm_model_observer>
|
||||
</observers>
|
||||
</sales_order_place_after>
|
||||
<!--<sales_order_save_after>-->
|
||||
<!--<observers>-->
|
||||
<!--<retailcrm_retailcrm_model_observer>-->
|
||||
<!--<type>singleton</type>-->
|
||||
<!--<class>Retailcrm_Retailcrm_Model_Observer</class>-->
|
||||
<!--<method>orderUpdate</method>-->
|
||||
<!--</retailcrm_retailcrm_model_observer>-->
|
||||
<!--</observers>-->
|
||||
<!--</sales_order_save_after>-->
|
||||
</events>
|
||||
</global>
|
||||
<crontab>
|
||||
|
@ -1,20 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright 2012 RetailCRM.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 RetailDriver LLC
|
||||
|
||||
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.
|
||||
-->
|
||||
<config>
|
||||
<tabs>
|
||||
@ -37,7 +43,7 @@
|
||||
<general translate="label comment" module="retailcrm">
|
||||
<expanded>1</expanded>
|
||||
<label>General</label>
|
||||
<comment>General settings that are required to connect retailcrm and Magento.</comment>
|
||||
<comment>General settings that are required to connect RetailCRM and Magento.</comment>
|
||||
<frontend_type>text</frontend_type>
|
||||
<sort_order>10</sort_order>
|
||||
<show_in_default>1</show_in_default>
|
||||
@ -65,7 +71,7 @@
|
||||
</fields>
|
||||
</general>
|
||||
<shipping translate="label comment" module="retailcrm">
|
||||
<expanded>1</expanded>
|
||||
<expanded>0</expanded>
|
||||
<label>Shipping methods</label>
|
||||
<comment>Comparison of shipping methods</comment>
|
||||
<frontend_type>text</frontend_type>
|
||||
@ -76,7 +82,7 @@
|
||||
<frontend_model>retailcrm/adminhtml_system_config_form_fieldset_shipping</frontend_model>
|
||||
</shipping>
|
||||
<payment translate="label comment" module="retailcrm">
|
||||
<expanded>1</expanded>
|
||||
<expanded>0</expanded>
|
||||
<label>Payment methods</label>
|
||||
<comment>Comparison of payment methods</comment>
|
||||
<frontend_type>text</frontend_type>
|
||||
@ -87,7 +93,7 @@
|
||||
<frontend_model>retailcrm/adminhtml_system_config_form_fieldset_payment</frontend_model>
|
||||
</payment>
|
||||
<payment_status translate="label comment" module="retailcrm">
|
||||
<expanded>1</expanded>
|
||||
<expanded>0</expanded>
|
||||
<label>Payment statuses</label>
|
||||
<comment>Comparison of payment statuses</comment>
|
||||
<frontend_type>text</frontend_type>
|
||||
@ -98,7 +104,7 @@
|
||||
<frontend_model>retailcrm/adminhtml_system_config_form_fieldset_paymentstatus</frontend_model>
|
||||
</payment_status>
|
||||
<status translate="label comment" module="retailcrm">
|
||||
<expanded>1</expanded>
|
||||
<expanded>0</expanded>
|
||||
<label>Order statuses</label>
|
||||
<comment>Comparison of order statuses</comment>
|
||||
<frontend_type>text</frontend_type>
|
||||
|
@ -1,20 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright 2012 RetailCRM.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 RetailDriver LLC
|
||||
|
||||
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.
|
||||
-->
|
||||
<config>
|
||||
<modules>
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<package>
|
||||
<name>retailcrm</name>
|
||||
<version>1.1.0</version>
|
||||
<stability>stable</stability>
|
||||
<license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</license>
|
||||
<channel>community</channel>
|
||||
<extends/>
|
||||
<summary>RetailCRM.</summary>
|
||||
<description>Description</description>
|
||||
<notes>Notes</notes>
|
||||
<authors><author><name>Alex Lushpai</name><user>gwinn</user><email>lushpai@gmail.com</email></author></authors>
|
||||
<date>2015-01-28</date>
|
||||
<time>16:22:48</time>
|
||||
<contents>
|
||||
<target name="magecommunity">
|
||||
<dir name="Retailcrm">
|
||||
<dir name="Retailcrm"></dir>
|
||||
</dir>
|
||||
</target>
|
||||
</contents>
|
||||
<compatible/>
|
||||
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
||||
</package>
|
Loading…
Reference in New Issue
Block a user