order status, order items
This commit is contained in:
parent
a0305e202e
commit
f370e6d085
@ -61,7 +61,7 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Payment ex
|
||||
{
|
||||
$configData = $this->getConfigData();
|
||||
|
||||
$path = 'retailcrm/payment/'.$group->getId();
|
||||
$path = 'retailcrm/payment/' . $group->getId();
|
||||
if (isset($configData[$path])) {
|
||||
$data = $configData[$path];
|
||||
$inherit = false;
|
||||
@ -71,7 +71,7 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Payment ex
|
||||
}
|
||||
|
||||
|
||||
$field = $fieldset->addField($group->getId(), 'select',
|
||||
$field = $fieldset->addField('payment_' . $group->getId(), 'select',
|
||||
array(
|
||||
'name' => 'groups[payment][fields]['.$group->getId().'][value]',
|
||||
'label' => Mage::getStoreConfig('payment/'.$group->getId().'/title'),
|
||||
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Paymentstatus extends Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Base
|
||||
{
|
||||
|
||||
public function render(Varien_Data_Form_Element_Abstract $element)
|
||||
{
|
||||
$html = $this->_getHeaderHtml($element);
|
||||
|
||||
if(!empty($this->_apiUrl) && !empty($this->_apiKey) && $this->_isCredentialCorrect) {
|
||||
|
||||
$client = Mage::getModel(
|
||||
'retailcrm/ApiClient',
|
||||
array('url' => $this->_apiUrl, 'key' => $this->_apiKey, 'site' => null)
|
||||
);
|
||||
|
||||
try {
|
||||
$paymentStatuses = $client->paymentStatusesList();
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log($e->getMessage());
|
||||
}
|
||||
|
||||
if ($paymentStatuses->isSuccessful() && !empty($paymentStatuses)) {
|
||||
foreach ($paymentStatuses['paymentStatuses'] 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 .= $this->_getFooterHtml($element);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _getFieldRenderer()
|
||||
{
|
||||
if (empty($this->_fieldRenderer)) {
|
||||
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
|
||||
}
|
||||
return $this->_fieldRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function _getValues()
|
||||
{
|
||||
$values = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_values;
|
||||
}
|
||||
|
||||
protected function _getFieldHtml($fieldset, $group)
|
||||
{
|
||||
$configData = $this->getConfigData();
|
||||
|
||||
$path = 'retailcrm/paymentstatus/'.$group['code'];
|
||||
|
||||
if (isset($configData[$path])) {
|
||||
$data = $configData[$path];
|
||||
$inherit = false;
|
||||
} else {
|
||||
$data = (int)(string)$this->getForm()->getConfigRoot()->descend($path);
|
||||
$inherit = true;
|
||||
}
|
||||
|
||||
$field = $fieldset->addField($group['code'], 'select',
|
||||
array(
|
||||
'name' => 'groups[paymentstatus][fields]['.$group['code'].'][value]',
|
||||
'label' => $group['name'],
|
||||
'value' => $data,
|
||||
'values' => $this->_getValues(),
|
||||
'inherit' => $inherit,
|
||||
'can_use_default_value' => 1,
|
||||
'can_use_website_value' => 1
|
||||
))->setRenderer($this->_getFieldRenderer());
|
||||
|
||||
return $field->toHtml();
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Shipping e
|
||||
{
|
||||
public function render(Varien_Data_Form_Element_Abstract $element)
|
||||
{
|
||||
Mage::getModel( "retailcrm/exchange" )->ordersHistory();
|
||||
$html = $this->_getHeaderHtml($element);
|
||||
|
||||
if(!empty($this->_apiUrl) && !empty($this->_apiKey) && $this->_isCredentialCorrect) {
|
||||
@ -63,7 +62,7 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Shipping e
|
||||
{
|
||||
$configData = $this->getConfigData();
|
||||
|
||||
$path = 'retailcrm/shipping/'.$group->getId();
|
||||
$path = 'retailcrm/shipping/' . $group->getId();
|
||||
if (isset($configData[$path])) {
|
||||
$data = $configData[$path];
|
||||
$inherit = false;
|
||||
@ -73,7 +72,7 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Shipping e
|
||||
}
|
||||
|
||||
|
||||
$field = $fieldset->addField($group->getId(), 'select',
|
||||
$field = $fieldset->addField('shipping_' . $group->getId(), 'select',
|
||||
array(
|
||||
'name' => 'groups[shipping][fields]['.$group->getId().'][value]',
|
||||
'label' => Mage::getStoreConfig('carriers/'.$group->getId().'/title'),
|
||||
|
@ -1,46 +1,20 @@
|
||||
<?php
|
||||
class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status extends Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Base
|
||||
{
|
||||
|
||||
public function render(Varien_Data_Form_Element_Abstract $element)
|
||||
{
|
||||
$html = $this->_getHeaderHtml($element);
|
||||
$warn = '
|
||||
<div style="margin-left: 15px;">
|
||||
<b><i>Please check your API Url & API Key</i></b>
|
||||
</div>
|
||||
';
|
||||
|
||||
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)
|
||||
)
|
||||
);
|
||||
|
||||
$values[] = array('code' => $value, 'name' => $label);
|
||||
}
|
||||
$statuses = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
$html .= $this->_getFieldHtml($element, $status);
|
||||
}
|
||||
|
||||
if (!empty($values)) {
|
||||
foreach ($values as $group) {
|
||||
$html.= $this->_getFieldHtml($element, $group);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$html .= $warn;
|
||||
$html .= '<div style="margin-left: 15px;"><b><i>Please check your API Url & API Key</i></b></div>';
|
||||
}
|
||||
|
||||
$html .= $this->_getFooterHtml($element);
|
||||
@ -51,9 +25,7 @@ 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;
|
||||
}
|
||||
@ -63,36 +35,26 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
*/
|
||||
protected function _getValues()
|
||||
{
|
||||
$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' => ''
|
||||
if(!empty($this->_apiUrl) && !empty($this->_apiKey) && $this->_isCredentialCorrect) {
|
||||
$client = Mage::getModel(
|
||||
'retailcrm/ApiClient',
|
||||
array('url' => $this->_apiUrl, 'key' => $this->_apiKey, 'site' => null)
|
||||
);
|
||||
if ($statuses->isSuccessful() && !empty($statuses)) {
|
||||
foreach ($statuses['statuses'] as $status) {
|
||||
$this->_values[] = array(
|
||||
'label' => Mage::helper('adminhtml')
|
||||
->__($status['name']),
|
||||
'value' => $status['code']
|
||||
);
|
||||
|
||||
try {
|
||||
$statuses = $client->statusesList();
|
||||
} catch (Retailcrm_Retailcrm_Model_Exception_CurlException $e) {
|
||||
Mage::log($e->getMessage());
|
||||
}
|
||||
|
||||
if ($statuses->isSuccessful()) {
|
||||
if (empty($this->_values)) {
|
||||
foreach ($statuses['statuses'] as $status) {
|
||||
$this->_values[] = array('label'=>Mage::helper('adminhtml')->__($status['name']), 'value'=>$status['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->_values;
|
||||
@ -102,24 +64,22 @@ class Retailcrm_Retailcrm_Block_Adminhtml_System_Config_Form_Fieldset_Status ext
|
||||
{
|
||||
$configData = $this->getConfigData();
|
||||
|
||||
$path = 'retailcrm/status/'.$group['code'];
|
||||
|
||||
$path = 'retailcrm/status/' . $group['status'];
|
||||
if (isset($configData[$path])) {
|
||||
$data = $configData[$path];
|
||||
$inherit = false;
|
||||
} else {
|
||||
$data = (int) (string) $this->getForm()
|
||||
->getConfigRoot()->descend($path);
|
||||
$data = (int)(string)$this->getForm()->getConfigRoot()->descend($path);
|
||||
$inherit = true;
|
||||
}
|
||||
|
||||
$field = $fieldset->addField($group['code'], 'select',
|
||||
$field = $fieldset->addField('status_' . $group['status'], 'select',
|
||||
array(
|
||||
'name' => 'groups[status][fields]['.$group['code'].'][value]',
|
||||
'label' => $group['name'],
|
||||
'value' => $data,
|
||||
'values' => $this->_getValues(),
|
||||
'inherit' => $inherit,
|
||||
'name' => 'groups[status][fields]['.$group['status'].'][value]',
|
||||
'label' => $group['label'],
|
||||
'value' => $data,
|
||||
'values' => $this->_getValues(),
|
||||
'inherit' => $inherit,
|
||||
'can_use_default_value' => 1,
|
||||
'can_use_website_value' => 1
|
||||
))->setRenderer($this->_getFieldRenderer());
|
||||
|
@ -30,23 +30,56 @@ class Retailcrm_Retailcrm_Model_Exchange
|
||||
$this->_config = Mage::getStoreConfig('retailcrm', $order->getStoreId());
|
||||
|
||||
$statuses = array_flip(array_filter($this->_config['status']));
|
||||
$paymentsStatuses = array_flip(array_filter($this->_config['paymentstatus']));
|
||||
$payments = array_filter($this->_config['payment']);
|
||||
$shippings = array_filter($this->_config['shipping']);
|
||||
|
||||
$address = $order->getShippingAddress()->getData();
|
||||
|
||||
$orderItems = $order->getItemsCollection();
|
||||
$items = array();
|
||||
$orderItems = $order->getAllItems();
|
||||
$simpleItems = array();
|
||||
$confItems = array();
|
||||
|
||||
foreach ($orderItems as $item){
|
||||
$items[] = array(
|
||||
foreach ($orderItems as $item) {
|
||||
if ($item->getProductType() == 'simple') {
|
||||
$simpleItems[] = $item;
|
||||
} else {
|
||||
$confItems[$item->getData('item_id')] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$items = array();
|
||||
|
||||
foreach ($simpleItems as $item) {
|
||||
|
||||
$product = array(
|
||||
'productId' => $item->product_id,
|
||||
'initialPrice' => $item->getPrice(),
|
||||
'taxPrice' => $item->getPriceInclTax(),
|
||||
'productName' => $item->getName(),
|
||||
'quantity' => (int) $item->getData('qty_ordered')
|
||||
);
|
||||
|
||||
if ($item->getData('parent_item_id')) {
|
||||
$product['initialPrice'] = $confItems[$item->getData('parent_item_id')]->getPrice();
|
||||
|
||||
/*if ($confItems[$item->getData('parent_item_id')]->getDiscountAmount() > 0) {
|
||||
$product['discount'] = $confItems[$item->getData('parent_item_id')]->getDiscountAmount();
|
||||
}
|
||||
|
||||
if ($confItems[$item->getData('parent_item_id')]->getDiscountPercent() > 0) {
|
||||
$product['discountPercent'] = $confItems[$item->getData('parent_item_id')]->getDiscountPercent();
|
||||
}*/
|
||||
} else {
|
||||
$product['initialPrice'] = $item->getPrice();
|
||||
|
||||
/*if ($item->getDiscountAmount() > 0) {
|
||||
$product['discount'] = $item->getDiscountAmount();
|
||||
}
|
||||
|
||||
if ($item->getDiscountPercent() > 0) {
|
||||
$product['discountPercent'] = $item->getDiscountPercent();
|
||||
}*/
|
||||
}
|
||||
|
||||
$items[] = $product;
|
||||
}
|
||||
|
||||
$customer = array(
|
||||
@ -74,8 +107,7 @@ class Retailcrm_Retailcrm_Model_Exchange
|
||||
'email' => $order->getCustomerEmail(),
|
||||
'phone' => $address['telephone'],
|
||||
'paymentType' => $payments[$order->getPayment()->getMethodInstance()->getCode()],
|
||||
//'paymentStatus' => $paymentsStatuses[$order->getStatus()],
|
||||
//'status' => $statuses[$order->getStatus()],
|
||||
'status' => $statuses[$order->getStatus()],
|
||||
'discount' => abs($order->getDiscountAmount()),
|
||||
'items' => $items,
|
||||
'delivery' => array(
|
||||
|
@ -89,21 +89,11 @@ SOFTWARE.
|
||||
<show_in_store>1</show_in_store>
|
||||
<frontend_model>retailcrm/adminhtml_system_config_form_fieldset_payment</frontend_model>
|
||||
</payment>
|
||||
<payment_status translate="label comment" module="retailcrm">
|
||||
<expanded>0</expanded>
|
||||
<label>Payment Information</label>
|
||||
<frontend_type>text</frontend_type>
|
||||
<sort_order>13</sort_order>
|
||||
<show_in_default>1</show_in_default>
|
||||
<show_in_website>1</show_in_website>
|
||||
<show_in_store>1</show_in_store>
|
||||
<frontend_model>retailcrm/adminhtml_system_config_form_fieldset_paymentstatus</frontend_model>
|
||||
</payment_status>
|
||||
<status translate="label comment" module="retailcrm">
|
||||
<expanded>0</expanded>
|
||||
<label>Order Statuses</label>
|
||||
<frontend_type>text</frontend_type>
|
||||
<sort_order>14</sort_order>
|
||||
<sort_order>13</sort_order>
|
||||
<show_in_default>1</show_in_default>
|
||||
<show_in_website>1</show_in_website>
|
||||
<show_in_store>1</show_in_store>
|
||||
|
Loading…
Reference in New Issue
Block a user