Ecomwise_MshopB2B - Version 1.2.7

Version Notes

1.2.7

Download this release

Release Info

Developer EcomwiseTeam
Extension Ecomwise_MshopB2B
Version 1.2.7
Comparing to
See all releases


Version 1.2.7

Files changed (53) hide show
  1. app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwiseCustomerGrid.php +189 -0
  2. app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwisePromoCatalogEditTab.php +60 -0
  3. app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwisePromoCatalogGrid.php +222 -0
  4. app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/Grid/Filter/Contactgroup.php +20 -0
  5. app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/Sales/Order/Create/Shipping/Method/Form.php +39 -0
  6. app/code/community/Ecomwise/MshopB2B/Block/Customerattribute/Helper/Mamutgroups.php +67 -0
  7. app/code/community/Ecomwise/MshopB2B/Block/Renderers/CompanyRenderer.php +20 -0
  8. app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogCustomer.php +35 -0
  9. app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogFilterCustomer.php +15 -0
  10. app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogFilterCustomerGroup.php +15 -0
  11. app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogRenderer.php +62 -0
  12. app/code/community/Ecomwise/MshopB2B/Block/Renderers/MamutContactRenderer.php +18 -0
  13. app/code/community/Ecomwise/MshopB2B/Block/Renderers/MamutIDRenderer.php +24 -0
  14. app/code/community/Ecomwise/MshopB2B/Block/System/Config/Version.php +7 -0
  15. app/code/community/Ecomwise/MshopB2B/Helper/Contactgroup.php +19 -0
  16. app/code/community/Ecomwise/MshopB2B/Helper/Data.php +38 -0
  17. app/code/community/Ecomwise/MshopB2B/Model/Api/Credit/Api.php +79 -0
  18. app/code/community/Ecomwise/MshopB2B/Model/Api/Credit/Api/V2.php +5 -0
  19. app/code/community/Ecomwise/MshopB2B/Model/Api/Customer/Api.php +450 -0
  20. app/code/community/Ecomwise/MshopB2B/Model/Api/Customer/Api/V2.php +5 -0
  21. app/code/community/Ecomwise/MshopB2B/Model/Api/Mamut/Api.php +95 -0
  22. app/code/community/Ecomwise/MshopB2B/Model/Api/Mamut/Api/V2.php +5 -0
  23. app/code/community/Ecomwise/MshopB2B/Model/Api/Promotions/Api.php +525 -0
  24. app/code/community/Ecomwise/MshopB2B/Model/Api/Promotions/Api/V2.php +6 -0
  25. app/code/community/Ecomwise/MshopB2B/Model/Carrier/Mamutshipping.php +39 -0
  26. app/code/community/Ecomwise/MshopB2B/Model/Catalogpromotions.php +89 -0
  27. app/code/community/Ecomwise/MshopB2B/Model/Collections/RuleCollection.php +21 -0
  28. app/code/community/Ecomwise/MshopB2B/Model/Customer/Group.php +13 -0
  29. app/code/community/Ecomwise/MshopB2B/Model/Customerattribute/Backend/Mamutgroups.php +64 -0
  30. app/code/community/Ecomwise/MshopB2B/Model/Customerattribute/Source/Mamutgroups.php +32 -0
  31. app/code/community/Ecomwise/MshopB2B/Model/Observer.php +80 -0
  32. app/code/community/Ecomwise/MshopB2B/Model/Payment/Mamutbilling.php +13 -0
  33. app/code/community/Ecomwise/MshopB2B/Model/Rules/CatalogRule.php +55 -0
  34. app/code/community/Ecomwise/MshopB2B/Model/Rules/Combine.php +17 -0
  35. app/code/community/Ecomwise/MshopB2B/Model/Rules/MySQL4Rule.php +284 -0
  36. app/code/community/Ecomwise/MshopB2B/Model/Sales/Tax/Subtotal.php +75 -0
  37. app/code/community/Ecomwise/MshopB2B/Model/SalesRule/Validator.php +215 -0
  38. app/code/community/Ecomwise/MshopB2B/controllers/CartController.php +38 -0
  39. app/code/community/Ecomwise/MshopB2B/controllers/OrderController.php +45 -0
  40. app/code/community/Ecomwise/MshopB2B/etc/api.xml +427 -0
  41. app/code/community/Ecomwise/MshopB2B/etc/config.xml +197 -0
  42. app/code/community/Ecomwise/MshopB2B/etc/system.xml +69 -0
  43. app/code/community/Ecomwise/MshopB2B/etc/wsdl.xml +886 -0
  44. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-install-1.2.2.php +117 -0
  45. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.0-1.2.1.php +41 -0
  46. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.1-1.2.2.php +42 -0
  47. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.2-1.2.3.php +75 -0
  48. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.3-1.2.4.php +19 -0
  49. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.4-1.2.5.php +7 -0
  50. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.5-1.2.6.php +12 -0
  51. app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.6-1.2.7.php +78 -0
  52. app/etc/modules/Ecomwise_MshopB2B.xml +10 -0
  53. package.xml +18 -0
app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwiseCustomerGrid.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customers grid override.
4
+ * Mamut ID field is added to the customer grid
5
+ **/
6
+
7
+ class Ecomwise_MshopB2B_Block_Adminhtml_EcomwiseCustomerGrid extends Mage_Adminhtml_Block_Customer_Grid{
8
+
9
+ protected function _prepareCollection(){
10
+ $resurce = Mage::getSingleton('core/resource');
11
+ $table_name = $resurce->getTableName('ecomwise_customermamut_mapping');
12
+ $customer_entity_text = $resurce->getTableName('customer_entity_text');
13
+
14
+ /* get mamut_contact_groups attribute Id*/
15
+ $entityTypeId = Mage::getModel('eav/config')->getEntityType('customer')->getEntityTypeId();
16
+ $attribute = Mage::getResourceModel('eav/entity_attribute_collection')
17
+ ->setCodeFilter('mamut_contact_groups')
18
+ ->setEntityTypeFilter($entityTypeId)
19
+ ->getFirstItem();
20
+
21
+ $contactGroupAttrId = $attribute->getAttributeId();
22
+
23
+
24
+ $collection = Mage::getResourceModel('customer/customer_collection');
25
+
26
+
27
+ $collection->addNameToSelect()
28
+ ->addAttributeToSelect('email')
29
+ ->addAttributeToSelect('created_at')
30
+ ->addAttributeToSelect('group_id')
31
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
32
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
33
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
34
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
35
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
36
+ ->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
37
+ ->joinField('mamut_contact_groups',
38
+ $customer_entity_text,
39
+ 'value',
40
+ 'entity_id=entity_id',
41
+ "{{table}}.attribute_id='".$contactGroupAttrId."'",
42
+ 'left');
43
+
44
+ $collection->joinField('mamut_id_a',
45
+ 'mshopb2b/mshopb2b',
46
+ 'mamut_id',
47
+ 'customer_id=entity_id',
48
+ null,
49
+ 'left');
50
+ ;
51
+ $collection->addAttributeToSelect('mamut_contact_groups');
52
+
53
+ $this->setCollection($collection);
54
+
55
+ Mage::register('customer_c',$collection);
56
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
57
+
58
+ }
59
+
60
+
61
+ protected function _prepareColumns(){
62
+ $this->addColumn('entity_id', array(
63
+ 'header' => Mage::helper('customer')->__('ID'),
64
+ 'width' => '50px',
65
+ 'index' => 'entity_id',
66
+ 'type' => 'number',
67
+ ));
68
+
69
+ $this->addColumn('name', array(
70
+ 'header' => Mage::helper('customer')->__('Name'),
71
+ 'index' => 'name'
72
+ ));
73
+ $this->addColumn('email', array(
74
+ 'header' => Mage::helper('customer')->__('Email'),
75
+ 'width' => '140',
76
+ 'index' => 'email'
77
+ ));
78
+
79
+ $groups = Mage::getResourceModel('customer/group_collection')
80
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
81
+ ->load()
82
+ ->toOptionHash();
83
+
84
+ $this->addColumn('group', array(
85
+ 'header' => Mage::helper('customer')->__('Group'),
86
+ 'width' => '90',
87
+ 'index' => 'group_id',
88
+ 'type' => 'options',
89
+ 'options' => $groups,
90
+ ));
91
+
92
+ $this->addColumn('Telephone', array(
93
+ 'header' => Mage::helper('customer')->__('Telephone'),
94
+ 'width' => '90',
95
+ 'index' => 'billing_telephone'
96
+ ));
97
+
98
+ $this->addColumn('billing_postcode', array(
99
+ 'header' => Mage::helper('customer')->__('ZIP'),
100
+ 'width' => '70',
101
+ 'index' => 'billing_postcode',
102
+ ));
103
+
104
+ $this->addColumn('mamut_id', array(
105
+ 'header' => Mage::helper('customer')->__('Mamut Relation ID'),
106
+ 'width' => '20px',
107
+ 'index' => 'mamut_id_a',
108
+ 'type' => 'text',
109
+ // 'renderer' => 'mshopb2b/renderers_mamutIDRenderer',
110
+ ));
111
+
112
+ $contactOptions = array();
113
+ $contactOptions = Mage::helper('mshopb2b/contactgroup')->getOptionsForFilter();
114
+ $contactGroupFilter = 'mshopb2b/adminhtml_grid_filter_contactgroup';
115
+
116
+ $this->addColumn('mamut_contact_groups', array(
117
+ 'header' => Mage::helper('customer')->__('Mamut Contact Group'),
118
+ 'width' => '200px',
119
+ 'index' => 'mamut_contact_groups',
120
+ 'type' => 'options',
121
+ 'options' => $contactOptions,
122
+ 'filter' => $contactGroupFilter,
123
+ 'renderer' => 'mshopb2b/renderers_mamutContactRenderer',
124
+ ));
125
+
126
+ $this->addColumn('billing_company', array(
127
+ 'header' => Mage::helper('customer')->__('Company'),
128
+ 'width' => '70',
129
+ 'index' => 'billing_company',
130
+
131
+
132
+ ));
133
+
134
+ $this->addColumn('billing_country_id', array(
135
+ 'header' => Mage::helper('customer')->__('Country'),
136
+ 'width' => '80',
137
+ 'type' => 'country',
138
+ 'index' => 'billing_country_id',
139
+ ));
140
+
141
+ $this->addColumn('billing_region', array(
142
+ 'header' => Mage::helper('customer')->__('State/Province'),
143
+ 'width' => '80',
144
+ 'index' => 'billing_region',
145
+ ));
146
+
147
+ $this->addColumn('customer_since', array(
148
+ 'header' => Mage::helper('customer')->__('Customer Since'),
149
+ 'type' => 'datetime',
150
+ 'align' => 'center',
151
+ 'index' => 'created_at',
152
+ 'gmtoffset' => true
153
+ ));
154
+
155
+ if (!Mage::app()->isSingleStoreMode()) {
156
+ $this->addColumn('website_id', array(
157
+ 'header' => Mage::helper('customer')->__('Website'),
158
+ 'align' => 'center',
159
+ 'width' => '80px',
160
+ 'type' => 'options',
161
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
162
+ 'index' => 'website_id',
163
+ ));
164
+ }
165
+
166
+ $this->addColumn('action',
167
+ array(
168
+ 'header' => Mage::helper('customer')->__('Action'),
169
+ 'width' => '90',
170
+ 'type' => 'action',
171
+ 'getter' => 'getId',
172
+ 'actions' => array(
173
+ array(
174
+ 'caption' => Mage::helper('customer')->__('Edit'),
175
+ 'url' => array('base'=> '*/*/edit'),
176
+ 'field' => 'id'
177
+ )
178
+ ),
179
+ 'filter' => false,
180
+ 'sortable' => false,
181
+ 'index' => 'stores',
182
+ 'is_system' => true,
183
+ ));
184
+
185
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
186
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
187
+ return parent::_prepareColumns();
188
+ }
189
+ }
app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwisePromoCatalogEditTab.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ * Catalog rule edit tab form overide.
6
+ * Mamut ID field is added
7
+ * @author
8
+ *
9
+ */
10
+ class Ecomwise_MshopB2B_Block_Adminhtml_EcomwisePromoCatalogEditTab extends Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_Main{
11
+
12
+ protected function _prepareForm(){
13
+ $parent = parent::_prepareForm();
14
+
15
+ $parent_form = $parent->getForm();
16
+
17
+ return $parent_form;
18
+ }
19
+
20
+ protected function _toHtml(){
21
+ $parent_html = parent::_toHtml();
22
+ return $parent_html;
23
+ }
24
+
25
+ public function getRuleCustomers(){
26
+
27
+ $customers_rows = array();
28
+ $current_rule = Mage::registry('current_promo_catalog_rule');
29
+
30
+ if ($current_rule->getId()){
31
+ $main_resurce = Mage::getSingleton('core/resource');
32
+ $rules_table = $main_resurce->getTableName('ecomwise_catalogpromotions_mapping');
33
+
34
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
35
+
36
+ $query = $connection ->select()
37
+ ->from($rules_table, array('customer_id'))
38
+ ->where('rule_id = '. $current_rule->getId());
39
+
40
+ $customers_rows = $connection->fetchCol($query);
41
+ }
42
+
43
+ $customers_list = array();
44
+
45
+ if ($customers_rows){
46
+ $customer_collection = Mage::getResourceModel('customer/customer_collection')
47
+ ->addNameToSelect()
48
+ ->addAttributeToFilter('entity_id', $customers_rows)
49
+ ->load();
50
+
51
+ foreach ($customer_collection as $customer){
52
+ $customer_name = $customer->getName() . ' - ' . $customer->getEmail();
53
+ $customers_array = array('value'=>$customer->getId(),'label'=>$customer_name);
54
+ $customer_list[] = $customers_array;
55
+ }
56
+ }
57
+
58
+ return $customer_list;
59
+ }
60
+ }
app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/EcomwisePromoCatalogGrid.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *Catolog promotions grid override.
4
+ * mamuit id, mamut rule id, customer ids filds are added
5
+ *
6
+ */
7
+
8
+ class Ecomwise_MshopB2B_Block_Adminhtml_EcomwisePromoCatalogGrid extends Mage_Adminhtml_Block_Widget_Grid{
9
+
10
+ public function __construct(){
11
+ parent::__construct();
12
+ $this->setId('promo_catalog_grid');
13
+ $this->setDefaultSort('name');
14
+ $this->setDefaultDir('ASC');
15
+ $this->setSaveParametersInSession(true);
16
+ }
17
+
18
+ protected function _prepareCollection() {
19
+
20
+ $resurce = Mage::getSingleton('core/resource');
21
+ $table_name = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
22
+ $table_customermapping = $resurce->getTableName('ecomwise_customermamut_mapping');
23
+ $customer_table = $resurce->getTableName('customer_entity');
24
+ $cutomerGroups = $resurce->getTableName('catalogrule_customer_group');
25
+ $collection = Mage::getResourceModel('catalogrule/rule_collection');
26
+ $collection->getSelect()->joinLeft(array('mapping' => $table_name), 'main_table.rule_id = mapping.rule_id', array('mapping.mamut_id', 'mapping.mamut_rule_id'));
27
+ $collection->getSelect()->joinLeft(array('mappingCustomer' => $table_customermapping), 'mapping.mamut_id = mappingCustomer.mamut_id', array('mappingCustomer.customer_id'));
28
+ $collection->getSelect()->joinLeft(array('customer' => $customer_table), 'mappingCustomer.customer_id = customer.entity_id', array('customer.email'));
29
+
30
+ if(version_compare(Mage::getVersion(),'1.7.0.0','>=')){
31
+ $collection->getSelect()->joinLeft(array('cgroups' => $cutomerGroups),'main_table.rule_id = cgroups.rule_id',array('*'));
32
+ }
33
+ $collection->getSelect()->group('main_table.rule_id');
34
+
35
+ $this->setCollection($collection);
36
+ return parent::_prepareCollection();
37
+
38
+
39
+ }
40
+
41
+ protected function _prepareColumns(){
42
+ $this->addColumn('rule_id', array(
43
+ 'header' => Mage::helper('catalogrule')->__('ID'),
44
+ 'align' =>'right',
45
+ 'width' => '50px',
46
+ 'index' => 'rule_id',
47
+ 'filter_index'=>'main_table.rule_id',
48
+ ));
49
+
50
+ $this->addColumn('name', array(
51
+ 'header' => Mage::helper('catalogrule')->__('Rule Name'),
52
+ 'align' =>'left',
53
+ 'index' => 'name',
54
+ ));
55
+
56
+ $this->addColumn('from_date', array(
57
+ 'header' => Mage::helper('catalogrule')->__('Date Start'),
58
+ 'align' => 'left',
59
+ 'width' => '120px',
60
+ 'type' => 'date',
61
+ 'index' => 'from_date',
62
+ ));
63
+
64
+ $this->addColumn('to_date', array(
65
+ 'header' => Mage::helper('catalogrule')->__('Date Expire'),
66
+ 'align' => 'left',
67
+ 'width' => '120px',
68
+ 'type' => 'date',
69
+ 'default' => '--',
70
+ 'index' => 'to_date',
71
+ ));
72
+
73
+ $this->addColumn('is_active', array(
74
+ 'header' => Mage::helper('catalogrule')->__('Status'),
75
+ 'align' => 'left',
76
+ 'width' => '80px',
77
+ 'index' => 'is_active',
78
+ 'type' => 'options',
79
+ 'options' => array(
80
+ 1 => 'Active',
81
+ 0 => 'Inactive',
82
+ ),
83
+ ));
84
+
85
+ $this->addColumn('mamut_id', array(
86
+ 'header' => Mage::helper('catalogrule')->__('Mamut Relation ID'),
87
+ 'align' =>'right',
88
+ 'width' => '50px',
89
+ 'index' => 'mamut_id',
90
+ ));
91
+
92
+ $this->addColumn('mamut_rule_id', array(
93
+ 'header' => Mage::helper('catalogrule')->__('Mamut Rule ID'),
94
+ 'align' =>'right',
95
+ 'width' => '50px',
96
+ 'index' => 'mamut_rule_id',
97
+ ));
98
+
99
+ $resurce_model = Mage::getModel('mshopb2b/catalogpromotions');
100
+ $customers = $resurce_model->get_customers();
101
+
102
+ $customer_groups = $resurce_model->get_customer_groups();
103
+ if(version_compare(Mage::getVersion(),'1.7.0.0','>=')){
104
+ $this->addColumn('customer_group_id', array(
105
+ 'header' => Mage::helper('salesrule')->__('Customer Groups'),
106
+ 'align' => 'left',
107
+ 'width' => '120px',
108
+ 'index' => 'customer_group_id',
109
+ 'renderer' => 'mshopb2b/renderers_gridCatalogRenderer',
110
+ 'filter' => 'mshopb2b/renderers_gridCatalogFilterCustomerGroup',
111
+ 'options' => $customer_groups,
112
+ ));
113
+ }else{
114
+ $this->addColumn('customer_group_ids', array(
115
+ 'header' => Mage::helper('salesrule')->__('Customer Groups'),
116
+ 'align' => 'left',
117
+ 'width' => '120px',
118
+ 'index' => 'customer_group_ids',
119
+ 'renderer' => 'mshopb2b/renderers_gridCatalogRenderer',
120
+ 'filter' => 'mshopb2b/renderers_gridCatalogFilterCustomerGroup',
121
+ 'options' => $customer_groups,
122
+ ));
123
+ }
124
+
125
+ /*$this->addColumn('customer_ids', array(
126
+ 'header' => Mage::helper('salesrule')->__('Individual Customers'),
127
+ 'align' => 'left',
128
+ 'width' => '260px',
129
+ 'index' => 'mapping.mamut_id',
130
+ 'renderer' => 'mshopb2b/renderers_gridCatalogCustomer',
131
+ 'filter' => 'adminhtml/widget_grid_column_filter_select',
132
+ 'options' => $customers,
133
+ ));*/
134
+ $this->addColumn('email', array(
135
+ 'header' => Mage::helper('salesrule')->__('Individual Customers'),
136
+ 'align' => 'left',
137
+ 'width' => '260px',
138
+ //'index' => 'mapping.mamut_id',
139
+ 'index' => 'email',
140
+ 'renderer' => 'mshopb2b/renderers_gridCatalogCustomer',
141
+ //'filter' => 'adminhtml/widget_grid_column_filter_select',
142
+ //'options' => $customers,
143
+ ));
144
+
145
+ $this->addColumn('sort_order', array(
146
+ 'header' => Mage::helper('salesrule')->__('Priority'),
147
+ 'width' => '100px',
148
+ 'align' => 'right',
149
+ 'index' => 'sort_order',
150
+ ));
151
+
152
+ return parent::_prepareColumns();
153
+ }
154
+
155
+ public function getRowUrl($row){
156
+ return $this->getUrl('*/*/edit', array('id' => $row->getRuleId()));
157
+ }
158
+
159
+ protected function _afterLoadCollection(){
160
+ $collection = $this->getCollection();
161
+
162
+ $rules_ids = array();
163
+
164
+ foreach ($collection->load() as $rule){
165
+ if ($rule_id = $rule->getId()){
166
+ $rules_ids[] = $rule_id;
167
+ }
168
+ }
169
+
170
+ $customers_to_rule = array();
171
+ if ($rules_ids){
172
+
173
+ //$customers_to_rule = array();
174
+
175
+ $resurce_customers = Mage::getModel('mshopb2b/catalogpromotions');
176
+ $customers = $resurce_customers->get_customers();
177
+
178
+ $resurce = Mage::getSingleton('core/resource');
179
+ $mapping_table = $resurce->getTableName('ecomwise_customermamut_mapping');
180
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
181
+
182
+ foreach($rules_ids as $rule_id){
183
+ $mamut_id = $resurce_customers->getMamutId($rule_id);
184
+
185
+ if($mamut_id){
186
+ $result = $connection->query('SELECT * FROM '.$mapping_table.'
187
+ WHERE mamut_id = '.$mamut_id.'
188
+ ');
189
+ $rows = $result->fetchAll(PDO::FETCH_ASSOC);
190
+
191
+ if($rows){
192
+ foreach($rows as $row){
193
+
194
+ if (isset($customers[$row['customer_id']])){
195
+ $customers_to_rule[$rule_id][$row['customer_id']] = $customers[$row['customer_id']];
196
+ }
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ Mage::register('customerpromotions_catalog_rule_customers', $customers_to_rule);
203
+ return parent::_afterLoadCollection();
204
+ }
205
+
206
+ private function getMamutId($rule_id){
207
+ $resurce = Mage::getSingleton('core/resource');
208
+ $mapping_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
209
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
210
+
211
+ $result = $connection->query('SELECT * FROM '.$mapping_table.'
212
+ WHERE rule_id = '.$rule_id.'
213
+ LIMIT 1');
214
+ $row = $result->fetch(PDO::FETCH_ASSOC);
215
+
216
+ if($row){
217
+ return $row['mamut_id'];
218
+ }else{
219
+ return false;
220
+ }
221
+ }
222
+ }
app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/Grid/Filter/Contactgroup.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Adminhtml_Grid_Filter_Contactgroup extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
3
+ {
4
+ public function getCondition()
5
+ {
6
+ $resurce = Mage::getSingleton('core/resource');
7
+ $customer_entity_text = $resurce->getTableName('customer_entity_text');
8
+ $mamut_contact_groups = $resurce->getTableName('ecomwise_mamut_contact_groups');
9
+ $cw = $resurce->getConnection('core_write');
10
+
11
+ $collection = Mage::registry('customer_c');
12
+
13
+ $result = $cw->fetchRow("SELECT mamut_contact_group_name FROM ".$mamut_contact_groups."
14
+ WHERE group_id =".$this->getValue()."");
15
+
16
+ $collection->addAttributeToFilter('mamut_contact_groups', array('like' => '%'.$result['mamut_contact_group_name'].'%'));
17
+
18
+ return null;
19
+ }
20
+ }
app/code/community/Ecomwise/MshopB2B/Block/Adminhtml/Sales/Order/Create/Shipping/Method/Form.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_MshopB2B_Block_Adminhtml_Sales_Order_Create_Shipping_Method_Form
4
+ extends Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form
5
+ {
6
+ public function getShippingRates()
7
+ {
8
+ if (empty($this->_rates)) {
9
+ $groups = $this->getAddress()->getGroupedAllShippingRates();
10
+ /*
11
+ if (!empty($groups)) {
12
+
13
+ $ratesFilter = new Varien_Filter_Object_Grid();
14
+ $ratesFilter->addFilter($this->getStore()->getPriceFilter(), 'price');
15
+
16
+ foreach ($groups as $code => $groupItems) {
17
+ $groups[$code] = $ratesFilter->filter($groupItems);
18
+ }
19
+ }
20
+ */
21
+ $temp = array();
22
+ foreach($groups as $code => $_rates)
23
+ {
24
+ if($code == "mamut_shipping") continue;
25
+ $temp[$code] = $_rates;
26
+ }
27
+ return $this->_rates = $temp;
28
+ }
29
+
30
+ $temp = $this->_rates;
31
+ foreach($groups as $code => $_rates)
32
+ {
33
+ if($code == "mamut_shipping") continue;
34
+ $temp[$code] = $_rates;
35
+ }
36
+ $this->_rates = $temp;
37
+ return $this->_rates;
38
+ }
39
+ }
app/code/community/Ecomwise/MshopB2B/Block/Customerattribute/Helper/Mamutgroups.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Adminhtml additional helper block for sort by
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Ecomwise_MshopB2B_Block_Customerattribute_Helper_Mamutgroups
36
+ extends Varien_Data_Form_Element_Multiselect
37
+ {
38
+ /**
39
+ * Retrieve Element HTML fragment
40
+ *
41
+ * @return string
42
+ */
43
+ public function getElementHtml()
44
+ {
45
+ $disabled = false;
46
+ if (!$this->getValue()) {
47
+ $this->setData('disabled', 'disabled');
48
+ $disabled = true;
49
+ }
50
+ $html = parent::getElementHtml();
51
+ $htmlId = 'use_config_' . $this->getHtmlId();
52
+ $html .= '<input id="'.$htmlId.'" name="use_config[]" value="' . $this->getId() . '"';
53
+ $html .= ($disabled ? ' checked="checked"' : '');
54
+
55
+ if ($this->getReadonly()) {
56
+ $html .= ' disabled="disabled"';
57
+ }
58
+
59
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
60
+
61
+ $html .= ' <label for="'.$htmlId.'" class="normal">'
62
+ . Mage::helper('adminhtml')->__('Use All Available Attributes').'</label>';
63
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
64
+
65
+ return $html;
66
+ }
67
+ }
app/code/community/Ecomwise/MshopB2B/Block/Renderers/CompanyRenderer.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_companyRenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
3
+
4
+ public function render(Varien_Object $row){
5
+ $customer_id = $row->getData('entity_id');
6
+
7
+ $customer = Mage::getModel('customer/customer')->load($customer_id);
8
+ $customerAddressId = $customer->getDefaultBilling();
9
+ if ($customerAddressId){
10
+ $address = Mage::getModel('customer/address')->load($customerAddressId);
11
+ return $address->getData('company');
12
+ }else{
13
+ return null;
14
+ }
15
+
16
+
17
+
18
+ }
19
+ }
20
+
app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogCustomer.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_GridCatalogCustomer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
3
+
4
+ public function render(Varien_Object $row){
5
+
6
+ $customers = Mage::registry('customerpromotions_catalog_rule_customers');
7
+ $rule_id = $row->getData('rule_id');
8
+ if ($rule_id && $customers && isset($customers[$rule_id]) ){
9
+ $number_of_customers = 10;
10
+
11
+ $more_than_limit = false;
12
+
13
+ if (sizeof($customers[$rule_id]) > $number_of_customers){
14
+ $rule_customers = array_slice($customers[$rule_id], 0, $number_of_customers);
15
+ $more_than_limit = true;
16
+ }
17
+ else {
18
+ $rule_customers = $customers[$rule_id];
19
+ }
20
+
21
+ $html = implode('<br/>', $rule_customers);
22
+
23
+ if ($more_than_limit){
24
+ $html .= '<br/>...';
25
+ }
26
+
27
+ return $html;
28
+
29
+ }else{
30
+ return '&nbsp;';
31
+ }
32
+
33
+ }
34
+
35
+ }
app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogFilterCustomer.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_GridCatalogFilterCustomer extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select{
3
+
4
+ public function getCondition(){
5
+ if (is_null($this->getValue())) {
6
+ return null;
7
+ }
8
+ //return array('mapping.mamut_id' => 1011);
9
+ }
10
+
11
+
12
+ }
13
+
14
+
15
+ ?>
app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogFilterCustomerGroup.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_GridCatalogFilterCustomerGroup extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select{
3
+
4
+ public function getCondition(){
5
+ if (is_null($this->getValue())) {
6
+ return null;
7
+ }
8
+ return array('finset' => $this->getValue());
9
+ }
10
+
11
+
12
+ }
13
+
14
+
15
+ ?>
app/code/community/Ecomwise/MshopB2B/Block/Renderers/GridCatalogRenderer.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_GridCatalogRenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
3
+
4
+ public function render(Varien_Object $row){
5
+ if(version_compare(Mage::getVersion(),'1.7.0.0','>=')){
6
+ return $this->render17($row);
7
+ }else{
8
+ return $this->renderBase($row);
9
+ }
10
+ }
11
+
12
+
13
+ private function render17(Varien_Object $row){
14
+ $customers = array();
15
+ $resource = Mage::getSingleton('core/resource');
16
+ $cr = Mage::getSingleton('core/resource')->getConnection('core_read');
17
+ $cw = Mage::getSingleton('core/resource')->getConnection('core_write');
18
+ $table = $resource->getTableName('catalogrule_customer_group');
19
+ $tableGroups = $resource->getTableName('catalogrule_customer_group');
20
+
21
+ $query = $cr ->select()
22
+ ->from($table, array('customer_group_id'))
23
+ ->where('rule_id = ?', $row->getData('rule_id'));
24
+
25
+ $rows = $cr->fetchCol($query);
26
+
27
+ $groups ="";
28
+ foreach($rows as $row){
29
+ $group = Mage::getModel('customer/group')->load($row);
30
+ $groups.= $group->getCustomerGroupCode()."</br>";
31
+ }
32
+
33
+ return $groups;
34
+
35
+ }
36
+
37
+ private function renderBase(Varien_Object $row){
38
+ $groups = $row->getData($this->getColumn()->getIndex());
39
+
40
+ if ($groups || $groups == '0'){
41
+
42
+ $customerpromotions_model = Mage::getModel('mshopb2b/catalogpromotions');
43
+ $customer_groups = $customerpromotions_model->get_customer_groups();
44
+
45
+ $group_names = array();
46
+ foreach ($groups as $group_id){
47
+
48
+ if (isset($customer_groups[$group_id])){
49
+ $group_names[] = $customer_groups[$group_id];
50
+ }
51
+ }
52
+
53
+ $html = implode(', ', $group_names);
54
+
55
+ return $html;
56
+ }
57
+ else {
58
+ return ' ';
59
+ }
60
+ }
61
+
62
+ }
app/code/community/Ecomwise/MshopB2B/Block/Renderers/MamutContactRenderer.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_mamutContactRenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
3
+ public function render(Varien_Object $row)
4
+ {
5
+
6
+ $contactGroups = $row['mamut_contact_groups'];
7
+ $contactGroupsHtml = '';
8
+ $groups = explode(',',$contactGroups);
9
+
10
+ foreach ($groups as $group){
11
+ if($group){
12
+ $contactGroupsHtml .= '<div style="font-size: 90%; margin-bottom: 8px; border-bottom: 1px dotted #bcbcbc;">' . $group . '</div>';
13
+ }
14
+ }
15
+ return $contactGroupsHtml;
16
+ }
17
+ }
18
+
app/code/community/Ecomwise/MshopB2B/Block/Renderers/MamutIDRenderer.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_Renderers_mamutIDRenderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
3
+
4
+ public function render(Varien_Object $row){
5
+ $customer_id = $row->getData('entity_id');
6
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
7
+
8
+ $resurce = Mage::getSingleton('core/resource');
9
+ $mapping_table = $resurce->getTableName('ecomwise_customermamut_mapping');
10
+ $query = $connection ->select()
11
+ ->from($mapping_table, array('mamut_id'))
12
+ ->where('customer_id = ?', $customer_id)
13
+ ->limit(1);
14
+ $row_mamut = $connection->fetchRow($query);
15
+ if($row_mamut){
16
+ return $row_mamut['mamut_id'];
17
+
18
+ }else{
19
+ return 'NULL';
20
+ }
21
+
22
+ }
23
+ }
24
+
app/code/community/Ecomwise/MshopB2B/Block/System/Config/Version.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Block_System_Config_Version extends Mage_Adminhtml_Block_System_Config_Form_Field{
3
+
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
5
+ return (string) "v".Mage::getConfig()->getNode()->modules->Ecomwise_MshopB2B->version;
6
+ }
7
+ }
app/code/community/Ecomwise/MshopB2B/Helper/Contactgroup.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Helper_Contactgroup extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getOptionsForFilter()
5
+ {
6
+ $resource = Mage::getSingleton('core/resource');
7
+ $reader = $resource->getConnection('core_read');
8
+ $tablename = $resource->gettableName('ecomwise_mamut_contact_groups');
9
+
10
+ $rows = $reader->fetchAll("SELECT * FROM ".$tablename." WHERE mamut_contact_group_name !='MAMUT NOT LOGGED IN'");
11
+ if($rows){
12
+ foreach ($rows as $row){
13
+ $options[$row['group_id']] = $row['mamut_contact_group_name'];
14
+ }
15
+ return $options;
16
+ }
17
+ }
18
+
19
+ }
app/code/community/Ecomwise/MshopB2B/Helper/Data.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Helper_Data extends Mage_Adminhtml_Helper_Data{
3
+
4
+
5
+ public function log($method, $varname, $data){
6
+
7
+ Mage::log("---------------------------------------------------------------------------------", null, "mshopb2b.log");
8
+
9
+ Mage::log("Method name: ", null, "mshopb2b.log");
10
+ Mage::log($method, null, "mshopb2b.log");
11
+ Mage::log($varname, null, "mshopb2b.log");
12
+ Mage::log($data, null, "mshopb2b.log");
13
+
14
+ Mage::log("---------------------------------------------------------------------------------", null, "mshopb2b.log");
15
+
16
+ }
17
+
18
+ public function getRulesForCustomer($customer_id){
19
+
20
+ $rule_ids = array();
21
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
22
+
23
+ $resurce = Mage::getSingleton('core/resource');
24
+ $mapping_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
25
+
26
+ $result_mamut_id = $connection->fetchRow("select mamut_id from ".$resurce->getTableName('ecomwise_customermamut_mapping')."
27
+ where customer_id=?", $customer_id);
28
+ $result_rule_id = $connection->fetchAll("select rule_id from ".$resurce->getTableName('ecomwise_catalogpromotions_mapping')."
29
+ where mamut_id=?", $result_mamut_id['mamut_id']);
30
+
31
+ foreach($result_rule_id as $row){
32
+ $rule_ids[] = $row['rule_id'];
33
+ }
34
+
35
+
36
+ return $rule_ids;
37
+ }
38
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Credit/Api.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Api_Credit_Api extends Mage_Api_Model_Resource_Abstract{
3
+
4
+ public function block($email, $website_id = null){
5
+ if($email == '' || $email == null){
6
+ $this->_fault("email_not_sent");
7
+
8
+ }
9
+
10
+ //return true;
11
+ if($website_id == null ){
12
+ foreach (Mage::app()->getWebsites() as $website) {
13
+ $website_id = $website->getId();
14
+ break;
15
+ }
16
+ }
17
+
18
+ //return $email;
19
+
20
+ try{
21
+ $customer = Mage::getModel("customer/customer")->setWebsiteId($website_id)->loadByEmail($email);
22
+ }catch(Exception $ex){
23
+ return $this->_fault('invalid_data');
24
+ }
25
+
26
+ if($customer->getEntityId() == null){
27
+
28
+ $this->_fault("customer_not_exists");
29
+
30
+ }
31
+
32
+
33
+ try{
34
+ $customer->setMshopBloked("1");
35
+ $customer->save();
36
+
37
+ }catch(Extension $ex){
38
+ $this->_fault("invalid_data");
39
+
40
+ }
41
+
42
+ return true;
43
+ }
44
+
45
+ public function unblock($email, $website_id = null){
46
+ if($email == '' || $email == null){
47
+ $this->_fault("email_not_sent");
48
+
49
+ }
50
+
51
+ if($website_id == null ){
52
+ foreach (Mage::app()->getWebsites() as $website) {
53
+ $website_id = $website->getId();
54
+ break;
55
+ }
56
+ }
57
+
58
+ try{
59
+ $customer = Mage::getModel("customer/customer")->setWebsiteId($website_id)->loadByEmail($email);
60
+ }catch(Exception $ex){
61
+ return $this->_fault('invalid_data');
62
+ }
63
+
64
+ if($customer->getEntityId() == null){
65
+ $this->_fault("customer_not_exists");
66
+ }
67
+ try{
68
+ $customer->setMshopBloked(0);
69
+ $customer->save();
70
+ return true;
71
+ }catch(Extension $ex){
72
+ $this->_fault($ex->getMessage());
73
+
74
+ }
75
+
76
+ }
77
+
78
+
79
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Credit/Api/V2.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Api_Credit_Api_V2 extends Ecomwise_MshopB2B_Model_Api_Credit_Api{
3
+
4
+
5
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Customer/Api.php ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_MshopB2B_Model_Api_Customer_Api extends Mage_Api_Model_Resource_Abstract{
4
+
5
+ protected $resource;
6
+ protected $reader;
7
+ protected $writer;
8
+
9
+ protected function construct(){
10
+ $this->resource = Mage::getSingleton('core/resource');
11
+ $this->reader = $this->resource->getConnection('core_read');
12
+ $this->writer = $this->resource->getConnection('core_write');
13
+ }
14
+
15
+ public function updatePreferedLocale($mamutId, $input)
16
+ {
17
+ $mapping = array(
18
+ 'NO' => 'nn_NO',
19
+ 'SV' => 'sv_SE',
20
+ 'DA' => 'da_DK',
21
+ 'FI' => 'fi_FI',
22
+ 'EN' => 'en_US',
23
+ 'FR' => 'fr_FR',
24
+ 'DE' => 'de_DE',
25
+ 'ES' => 'es_ES',
26
+ 'IT' => 'it_IT',
27
+ 'PT' => 'pt_PT',
28
+ 'EL' => 'el_GR',
29
+ 'ZH' => 'zh_CN',
30
+ 'CS' => 'cs_CZ',
31
+ 'ID' => 'id_ID',
32
+ 'HE' => 'he_IL',
33
+ 'JA' => 'ja_JP',
34
+ 'MS' => 'ms_MY',
35
+ 'NL' => 'nl_NL',
36
+ 'RU' => 'ru_RU',
37
+ 'AR' => 'ar_SA',
38
+ 'KO' => 'ko_KR',
39
+ 'TH' => 'th_TH',
40
+ 'TR' => 'tr_TR',
41
+ 'IS' => 'is_IS'
42
+ );
43
+
44
+ $preferedLocale = 'en_US';
45
+ if($mapping[$input])
46
+ {
47
+ $preferedLocale = $mapping[$input];
48
+ }
49
+
50
+ $this->construct();
51
+ if($mamutId == 0 or $mamutId == null){
52
+ $this->_fault("customer_not_exists_for_mamut_id");
53
+ }
54
+ $customer_row = $this->reader->fetchRow("SELECT customer_id FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')."
55
+ WHERE mamut_id=?", $mamutId );
56
+
57
+ if($customer_row == null){
58
+ $this->_fault("customer_not_exists_for_mamut_id");
59
+ }
60
+ $customerId = $customer_row['customer_id'];
61
+ $customer = Mage::getModel('customer/customer')->load($customerId);
62
+
63
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'customer_language_locale');
64
+
65
+ if($attribute)
66
+ {
67
+ if($customer)
68
+ {
69
+ $customer->setCustomerLanguageLocale($preferedLocale);
70
+ try{
71
+ $customer->save();
72
+ return true;
73
+ }catch(Exception $e){
74
+ return false;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+ return false;
80
+ }
81
+
82
+ public function createCustomerGroup($groupName){
83
+
84
+ $customer_group = Mage::getModel('customer/group')->getCollection()->addFieldToFilter('customer_group_code', array('eq'=>$groupName));
85
+
86
+ if($customer_group->count() == 0){
87
+
88
+ Mage::getSingleton('customer/group')->setData(
89
+ array('customer_group_code' => $groupName,
90
+ 'tax_class_id' => 3)
91
+ )->save();
92
+
93
+ }
94
+ return true;
95
+ }
96
+
97
+ public function assignCustomerToGroup($customerId, $groupId){
98
+
99
+ $customer = Mage::getModel('customer/customer')->load($customerId);
100
+ if(!$customer->getId()){
101
+ $this->_fault("unknown_mcustomer");
102
+ }
103
+
104
+ $group = Mage::getModel('customer/group')->load($groupId);
105
+ if(!$group->getId()){
106
+ $this->_fault("unknown_mgroup");
107
+ }
108
+ $customer->setGroupId($groupId);
109
+ $customer->save();
110
+
111
+ return true;
112
+ }
113
+
114
+ public function update($magentoCustomerId, $customerData, $addressBillingData, $addressShippingData){
115
+ $this->construct();
116
+ $customer_id = $magentoCustomerId;
117
+
118
+ if($customer_id != '' && $customer_id != null && Mage::getModel('customer/customer')->load($customer_id)->getId()){
119
+ $customerId = $customer_id;
120
+ }else{
121
+ $mamut_id = $customerData->mamut_id;
122
+ if($mamut_id == '' or $mamut_id == null){
123
+ $this->_fault("customer_not_exists_for_mamut_id");
124
+ }
125
+ $customer_row = $this->reader->fetchRow("SELECT customer_id FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')."
126
+ WHERE mamut_id=?", $mamut_id );
127
+
128
+ if($customer_row == null){
129
+ $this->_fault("customer_not_exists_for_mamut_id");
130
+ }
131
+ $customerId = $customer_row['customer_id'];
132
+ }
133
+ //$customerEntity = $customerData->customerEntity;
134
+
135
+ $customer = Mage::getModel('customer/customer')->load($customerId);
136
+ if(!$customer->getId()){
137
+ $this->_fault("mapped_customer_not_exists_for_mamut_id");
138
+ }
139
+
140
+ $mamut_contact_groups = $customerData->mamut_contact_groups;
141
+ if(is_array($mamut_contact_groups)){
142
+ $this->updateMamutContactGroups($customer, $mamut_contact_groups );
143
+ }
144
+
145
+ $response1 = Mage::getModel('customer/customer_api')->update($customerId,
146
+ array(
147
+ email=>$customerData->email,
148
+ firstname=>$customerData->firstname,
149
+ lastname=>$customerData->lastname,
150
+ password=>$customerData->password,
151
+ website_id=>$customerData->website_id,
152
+ store_id=>$customerData->store_id,
153
+ group_id=>$customerData->group_id,
154
+ taxvat=>$customerData->taxvat
155
+ )
156
+ );
157
+ if(!$response1){
158
+ $this->_fault("customer_information_update_failed");
159
+ }
160
+
161
+ //update default billing address
162
+ $billingAdr = $customer->getDefaultBillingAddress();
163
+ if($billingAdr){
164
+ $addrId = $billingAdr->getId();
165
+ $response2 = Mage::getModel('customer/address_api')->update($addrId,
166
+ array(
167
+ city=>$addressBillingData->city,
168
+ company=>$addressBillingData->company,
169
+ country_id=>$addressBillingData->country_id,
170
+ fax=>$addressBillingData->fax,
171
+ firstname=>$addressBillingData->firstname,
172
+ lastname=>$addressBillingData->lastname,
173
+ middlename=>$addressBillingData->middlename,
174
+ postcode=>$addressBillingData->postcode,
175
+ prefix=>$addressBillingData->prefix,
176
+ region_id=>$addressBillingData->region_id,
177
+ region=>$addressBillingData->region,
178
+ street=>$addressBillingData->street,
179
+ suffix=>$addressBillingData->suffix,
180
+ telephone=>$addressBillingData->telephone,
181
+ is_default_billing=>1,
182
+ //is_default_shipping=>1,
183
+ )
184
+ );
185
+ if(!$response2){
186
+ $this->_fault("address_information_update_failed");
187
+ }
188
+ }else{
189
+ $response2 = Mage::getModel('customer/address_api')->create($customerId,
190
+ array(
191
+ city=>$addressBillingData->city,
192
+ company=>$addressBillingData->company,
193
+ country_id=>$addressBillingData->country_id,
194
+ fax=>$addressBillingData->fax,
195
+ firstname=>$addressBillingData->firstname,
196
+ lastname=>$addressBillingData->lastname,
197
+ middlename=>$addressBillingData->middlename,
198
+ postcode=>$addressBillingData->postcode,
199
+ prefix=>$addressBillingData->prefix,
200
+ region_id=>$addressBillingData->region_id,
201
+ region=>$addressBillingData->region,
202
+ street=>$addressBillingData->street,
203
+ suffix=>$addressBillingData->suffix,
204
+ telephone=>$addressBillingData->telephone,
205
+ is_default_billing=>1,
206
+ //is_default_shipping=>1,
207
+ )
208
+ );
209
+ if(!$response2){
210
+ $this->_fault("address_information_update_failed");
211
+ }
212
+ }
213
+
214
+ //update default shipping address
215
+ $shippingAdr = $customer->getDefaultShippingAddress();
216
+ if($shippingAdr){
217
+ $addrId = $shippingAdr->getId();
218
+ $response3 = Mage::getModel('customer/address_api')->update($addrId,
219
+ array(
220
+ city=>$addressShippingData->city,
221
+ company=>$addressShippingData->company,
222
+ country_id=>$addressShippingData->country_id,
223
+ fax=>$addressShippingData->fax,
224
+ firstname=>$addressShippingData->firstname,
225
+ lastname=>$addressShippingData->lastname,
226
+ middlename=>$addressShippingData->middlename,
227
+ postcode=>$addressShippingData->postcode,
228
+ prefix=>$addressShippingData->prefix,
229
+ region_id=>$addressShippingData->region_id,
230
+ region=>$addressShippingData->region,
231
+ street=>$addressShippingData->street,
232
+ suffix=>$addressShippingData->suffix,
233
+ telephone=>$addressShippingData->telephone,
234
+ //is_default_billing=>1,
235
+ is_default_shipping=>1,
236
+ )
237
+ );
238
+ if(!$response3){
239
+ $this->_fault("address_information_update_failed");
240
+ }
241
+ }else{
242
+ $response3 = Mage::getModel('customer/address_api')->create($customerId,
243
+ array(
244
+ city=>$addressShippingData->city,
245
+ company=>$addressShippingData->company,
246
+ country_id=>$addressShippingData->country_id,
247
+ fax=>$addressShippingData->fax,
248
+ firstname=>$addressShippingData->firstname,
249
+ lastname=>$addressShippingData->lastname,
250
+ middlename=>$addressShippingData->middlename,
251
+ postcode=>$addressShippingData->postcode,
252
+ prefix=>$addressShippingData->prefix,
253
+ region_id=>$addressShippingData->region_id,
254
+ region=>$addressShippingData->region,
255
+ street=>$addressShippingData->street,
256
+ suffix=>$addressShippingData->suffix,
257
+ telephone=>$addressShippingData->telephone,
258
+ //is_default_billing=>1,
259
+ is_default_shipping=>1,
260
+ )
261
+ );
262
+ if(!$response3){
263
+ $this->_fault("address_information_update_failed");
264
+ }
265
+ }
266
+ return true;
267
+ }
268
+
269
+
270
+ public function create($customerData, $addressBillingData, $addressShippingData){
271
+ $this->construct();
272
+ $errors = $this->validateCustomerData($customerData, $addressBillingData, $addressShippingData);
273
+
274
+ if(count($errors) > 0){
275
+ $this->_fault("customer_create_incomplete_data", "Incomplete customer creation data. Missing parts: ".implode(', ',$errors));
276
+
277
+ }
278
+ $customer = Mage::getModel("customer/customer")->setWebsiteId($customerData->website_id)->loadByEmail($customerData->email);
279
+ if($customer->getId()){
280
+ $this->_fault("customer_create_customer_allready_exists");
281
+ }
282
+ $customerId = Mage::getModel('customer/customer_api')->create(array(
283
+ 'email'=>$customerData->email,
284
+ 'firstname'=>$customerData->firstname,
285
+ 'lastname'=>$customerData->lastname,
286
+ 'password'=>$customerData->password,
287
+ 'website_id'=>$customerData->website_id,
288
+ 'store_id'=>$customerData->store_id,
289
+ 'group_id'=>$customerData->group_id,
290
+ 'taxvat'=>$customerData->taxvat
291
+ ));
292
+ if(!$customerId){
293
+ $this->_fault("customer_creation_failed");
294
+ }
295
+
296
+ $customer = Mage::getModel('customer/customer')->load($customerId);
297
+
298
+
299
+ $addressBillingData->is_default_billing = 1;
300
+ $response2 = Mage::getModel('customer/address_api_v2')->create($customerId, $addressBillingData);
301
+
302
+
303
+ $addressShippingData->is_default_shipping = 1;
304
+ $response3 = Mage::getModel('customer/address_api_v2')->create($customerId, $addressShippingData);
305
+
306
+ if(!$response2){
307
+ $this->_fault("address_creation_failed");
308
+ }
309
+ if(!$response3){
310
+ $this->_fault("address_creation_failed");
311
+ }
312
+
313
+ $mamut_contact_groups = $customerData->mamut_contact_groups;
314
+ if(is_array($mamut_contact_groups)){
315
+
316
+ $this->updateMamutContactGroups($customer, $mamut_contact_groups );
317
+ }
318
+
319
+ $setmamut = Mage::getModel('mshopb2b/api_mamut_api')->setMamutId($customerData->mamut_id, $customerId);
320
+
321
+ if(!$setmamut){
322
+ $this->_fault("mamut_id_not_set_for_customer");
323
+ }
324
+
325
+ return $customerId;
326
+ }
327
+
328
+ public function updatedSince($date){
329
+
330
+ $allCustomers = Mage::getModel('customer/customer')
331
+ ->getCollection()
332
+ ->addAttributeToSelect('updated_at')
333
+ ->addAttributeToFilter('email', array("neq"=>''))
334
+ ->addAttributeToFilter('updated_at', array('gt' => $date))
335
+ ->joinField('mamut_id_alias','mshopb2b/mshopb2b','mamut_id','customer_id=entity_id',null,'left')
336
+ ;
337
+
338
+ //return $allCustomers;
339
+
340
+ $cus_mamut_ids = array();
341
+ foreach ($allCustomers as $cus){
342
+ if($cus->getMamutIdAlias() != null){
343
+ $cus_mamut_ids[] = $cus->getMamutIdAlias() ;
344
+ }
345
+ }
346
+ return $cus_mamut_ids;
347
+
348
+ }
349
+ private function updateMamutContactGroups($customer, $mamut_contact_groups ){
350
+
351
+ $tablename = $this->resource->gettableName('ecomwise_mamut_contact_groups');
352
+
353
+ for($i =0; $i<count($mamut_contact_groups); $i++){
354
+
355
+ $group = trim($mamut_contact_groups[$i]);
356
+ $query = "SELECT * FROM ".$tablename." WHERE mamut_contact_group_name = '".$group."' ";
357
+ $row = $this->reader->fetchRow($query);
358
+ if(!$row){
359
+
360
+ $this->writer->query("INSERT INTO ".$tablename." (mamut_contact_group_name) values('".$group."')");
361
+ }
362
+ $mamut_contact_groups[$i] = $group;
363
+ }
364
+ $customer->setMamutContactGroups(implode(",", $mamut_contact_groups));
365
+ $customer->save();
366
+
367
+ return;
368
+
369
+ }
370
+
371
+
372
+ private function validateCustomerData($customerData, $billndAddress, $shippingAddress){
373
+ $errors = array();
374
+
375
+
376
+ if($customerData->email == null || $customerData->email == ''){
377
+ $errors [] = 'customer data:email';
378
+ }
379
+ if($customerData->firstname == null || $customerData->firstname == ''){
380
+ $errors [] = 'customer data:firstname';
381
+ }
382
+ if($customerData->lastname == null || $customerData->lastname == ''){
383
+ $errors [] = 'customer data:lastname';
384
+ }
385
+ if($customerData->website_id == null || $customerData->website_id == ''){
386
+ $errors [] = 'customer data:website_id';
387
+ }
388
+ if($customerData->group_id == null || $customerData->group_id == ''){
389
+ $errors [] = 'customer data:group_id';
390
+ }
391
+ if(Mage::getStoreConfig('customer/address/taxvat_show') == 'req'){
392
+ if($customerData->taxvat == null || $customerData->taxvat == ''){
393
+ $errors [] = 'customer data:taxvat';
394
+ }
395
+ }
396
+
397
+
398
+ if($billndAddress->firstname == null || $billndAddress->firstname == ''){
399
+ $errors [] = 'billing address:firstname';
400
+ }
401
+ if($billndAddress->lastname == null || $billndAddress->lastname == ''){
402
+ $errors [] = 'billing address:lastname';
403
+ }
404
+ if($billndAddress->street == null || $billndAddress->street == '' || count($billndAddress->street) == 0){
405
+ $errors [] = 'billing address:street';
406
+ }
407
+ if($billndAddress->city == null || $billndAddress->city == ''){
408
+ $errors [] = 'billing address:city';
409
+ }
410
+ if($billndAddress->country_id == null || $billndAddress->country_id == ''){
411
+ $errors [] = 'billing address:country_id';
412
+ }
413
+ if($billndAddress->postcode == null || $billndAddress->postcode == ''){
414
+ $errors [] = 'billing address:postcode';
415
+ }
416
+ if($billndAddress->telephone == null || $billndAddress->telephone == ''){
417
+ $errors [] = 'billing address:telephone';
418
+ }
419
+
420
+ if($shippingAddress->firstname == null || $shippingAddress->firstname == ''){
421
+ $errors [] = 'shipping address:firstname';
422
+ }
423
+ if($shippingAddress->lastname == null || $shippingAddress->lastname == ''){
424
+ $errors [] = 'shipping address:lastname';
425
+ }
426
+ if($shippingAddress->street == null || $shippingAddress->street == '' || count($shippingAddress->street) == 0){
427
+ $errors [] = 'shipping address:street';
428
+ }
429
+ if($shippingAddress->city == null || $shippingAddress->city == ''){
430
+ $errors [] = 'shipping address:city';
431
+ }
432
+ if($shippingAddress->country_id == null || $shippingAddress->country_id == ''){
433
+ $errors [] = 'shipping address:country_id';
434
+ }
435
+ if($shippingAddress->postcode == null || $shippingAddress->postcode == ''){
436
+ $errors [] = 'shipping address:postcode';
437
+ }
438
+ if($shippingAddress->telephone == null || $shippingAddress->telephone == ''){
439
+ $errors [] = 'shipping address:telephone';
440
+ }
441
+
442
+
443
+ return $errors;
444
+
445
+ }
446
+
447
+
448
+ }
449
+
450
+ ?>
app/code/community/Ecomwise/MshopB2B/Model/Api/Customer/Api/V2.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_MshopB2B_Model_Api_Customer_Api_V2 extends Ecomwise_MshopB2B_Model_Api_Customer_Api{
4
+
5
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Mamut/Api.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Api_Mamut_Api extends Mage_Api_Model_Resource_Abstract{
3
+
4
+ protected $resource;
5
+ protected $reader;
6
+ protected $writer;
7
+
8
+ protected function construct(){
9
+ $this->resource = Mage::getSingleton('core/resource');
10
+ $this->reader = $this->resource->getConnection('core_read');
11
+ $this->writer = $this->resource->getConnection('core_write');
12
+ }
13
+
14
+ public function setMamutId($mamutId, $customerId){
15
+ $this->construct();
16
+
17
+ if($mamutId == 0 or $mamutId == null or $customerId == 0 or $customerId == null){
18
+ $this->_fault("invalid_data_provided");
19
+ }
20
+
21
+
22
+
23
+ $customer = Mage::getModel("customer/customer")->load($customerId);
24
+ if(!$customer->getId()){
25
+
26
+ $this->_fault("magento_customer_not_exists");
27
+ }
28
+
29
+ $customer = $this->reader->fetchRow("SELECT customer_id FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')."
30
+ WHERE customer_id=?", $customerId );
31
+ if($customer != null){
32
+ $this->_fault("customer_id_allready_exists");
33
+ }
34
+
35
+ //$customermamut_mapping_row = $this->reader->fetchRow("SELECT customer_id, mamut_id FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')."
36
+ // WHERE customer_id=? and mamut_id=?", array($customerId, $mamutId) );
37
+
38
+ //if($customermamut_mapping_row == null){
39
+
40
+ try{
41
+ $sql = "INSERT INTO ".$this->resource->getTableName('ecomwise_customermamut_mapping')." values (?,?)";
42
+ $this->writer->query($sql, array($customerId,$mamutId));
43
+ return true;
44
+
45
+ }catch(Exception $ex){
46
+ Mage::log($ex->getMessage());
47
+ return false;
48
+ }
49
+
50
+ // }
51
+
52
+
53
+ }
54
+
55
+ public function removeMamutMapping($mamutId, $customerId){
56
+ $this->construct();
57
+
58
+ if($mamutId == 0 or $mamutId == null or $customerId == 0 or $customerId == null){
59
+ $this->_fault("invalid_data_provided");
60
+ }
61
+
62
+ $customermamut_mapping_row = $this->reader->fetchRow("SELECT mamut_id, customer_id FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')."
63
+ WHERE mamut_id=? AND customer_id=?", array($mamutId, $customerId) );
64
+
65
+ if($customermamut_mapping_row != null){
66
+ $sql = "DELETE FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')." WHERE mamut_id=? AND customer_id=?";
67
+ $this->writer->query($sql, array($mamutId, $customerId));
68
+ return true;
69
+ }else{
70
+ $this->_fault("mapping_not_found");
71
+ }
72
+ return false;
73
+ }
74
+
75
+ public function filterMamutMapping(){
76
+ $this->construct();
77
+ $rows = $this->reader->fetchAll("SELECT * FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')." ");
78
+
79
+ $count = 0;
80
+ foreach($rows as $row){
81
+ $cid = $row['customer_id'];
82
+ $cid_entity_row = $this->reader->fetchRow("SELECT * FROM ".$this->resource->getTableName('customer_entity')." WHERE entity_id = ".$cid." ;");
83
+ if(!$cid_entity_row){
84
+ $count++;
85
+ $this->writer->query("DELETE FROM ".$this->resource->getTableName('ecomwise_customermamut_mapping')." WHERE customer_id = ".$cid." ;");
86
+ }
87
+
88
+ }
89
+
90
+ return $count;
91
+ }
92
+
93
+ }
94
+
95
+ ?>
app/code/community/Ecomwise/MshopB2B/Model/Api/Mamut/Api/V2.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Api_Mamut_Api_V2 extends Ecomwise_MshopB2B_Model_Api_Mamut_Api
3
+ {
4
+
5
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Promotions/Api.php ADDED
@@ -0,0 +1,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Api_Promotions_Api extends Mage_Api_Model_Resource_Abstract
3
+ {
4
+
5
+ public function checkCreateFixedPriceForCustomer($mamutRuleId, $mamutCustomerId, $productSku, $fixedPrice){
6
+
7
+ $rule_id = 0;
8
+
9
+ $data = array(
10
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' fixed Price '.$fixedPrice,
11
+ 'is_active' => '1',
12
+ 'simple_action' => 'to_fixed',
13
+ 'discount_amount' => $fixedPrice,
14
+ );
15
+ $conditions = $this->setConditions("sku", $productSku);
16
+
17
+ $cus_groups = array();
18
+ if($cus_group = $this->getGroup($mamutCustomerId)){
19
+ $cus_groups[] = $cus_group;
20
+ }else{
21
+ $cus_groups[] = 1;
22
+ }
23
+
24
+ $rule_id = $this->createRule($data, $cus_groups, null, 1, $conditions);
25
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutCustomerId);
26
+
27
+ return $rule_id;
28
+ }
29
+
30
+ public function checkCreateDiscountForCustomer($mamutRuleId, $mamutCustomerId, $productSku, $discountPercentage){
31
+ $rule_id = 0;
32
+ $data = array(
33
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' discount percentage '.$discountPercentage,
34
+ 'is_active' => '1',
35
+ 'simple_action' => 'by_percent',
36
+ 'discount_amount' => $discountPercentage,
37
+ );
38
+
39
+ $conditions = $this->setConditions("sku", $productSku);
40
+
41
+ $cus_groups = array();
42
+ if($cus_group = $this->getGroup($mamutCustomerId)){
43
+ $cus_groups[] = $cus_group;
44
+ }else{
45
+ $cus_groups[] = 1;
46
+ }
47
+
48
+ $rule_id = $this->createRule($data, $cus_groups, null, 1, $conditions);
49
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutCustomerId);
50
+
51
+ return $rule_id;
52
+ }
53
+
54
+ public function checkCreateDefaultDiscountForCustomer($mamutRuleId, $mamutCustomerId, $discountPercentage){
55
+
56
+ $rule_id = 0;
57
+ $data = array(
58
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' discount percentage '.$discountPercentage." on all products",
59
+ 'is_active' => '1',
60
+ 'simple_action' => 'by_percent',
61
+ 'discount_amount' => $discountPercentage,
62
+ );
63
+
64
+ //$conditions = $this->setConditions("sku", $productSku);
65
+
66
+ $cus_groups = array();
67
+ if($cus_group = $this->getGroup($mamutCustomerId)){
68
+ $cus_groups[] = $cus_group;
69
+ }else{
70
+ $cus_groups[] = 1;
71
+ }
72
+
73
+ $rule_id = $this->createRule($data, $cus_groups, null, 1, null);
74
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutCustomerId);
75
+
76
+ return $rule_id;
77
+
78
+ }
79
+
80
+ public function checkCreateDiscountCategoryForCustomer($mamutRuleId, $mamutCustomerId, $categoryId, $discountPercentage){
81
+ /*$rule_id = 0;
82
+ $session_parameter = $mamutRuleId."-".$mamutCustomerId."-".$categoryId."-".$discountPercentage;
83
+
84
+ $data = array(
85
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' category discount percentage '.$discountPercentage,
86
+ 'is_active' => '1',
87
+ 'simple_action' => 'by_percent',
88
+ 'discount_amount' => $discountPercentage,
89
+ );
90
+
91
+ $conditions = $this->setConditions("category_ids", $categoryId);
92
+
93
+ $cus_groups = array();
94
+ if($cus_group = $this->getGroup($mamutCustomerId)){
95
+ $cus_groups[] = $cus_group;
96
+ }else{
97
+ $cus_groups[] = 1;
98
+ }
99
+
100
+ $rule_id = $this->createRule($data, $cus_groups , null, 1, $conditions);
101
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutCustomerId);
102
+
103
+ return $rule_id;*/
104
+
105
+ // $ruleIds = "";
106
+ // $category = Mage::getModel('catalog/category')->load($categoryId);
107
+ // $productCollection = $category->getProductCollection();
108
+ // foreach ($productCollection as $product){
109
+ // $ruleIds.=",".$this->createDiscountForCustomer($mamutRuleId,$mamutCustomerId,$product->getSku(),$discountPercentage);
110
+ // }
111
+ // return substr($ruleIds,1);
112
+
113
+ $rule_id = 0;
114
+ $data = array(
115
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' category discount percentage '.$discountPercentage,
116
+ 'is_active' => '1',
117
+ 'simple_action' => 'by_percent',
118
+ 'discount_amount' => $discountPercentage,
119
+ );
120
+
121
+ $productSkus = array();
122
+ $category = Mage::getModel('catalog/category')->load($categoryId);
123
+ $productCollection = $category->getProductCollection();
124
+
125
+ foreach ($productCollection as $product){
126
+ $productSkus[] = $product->getSku();
127
+ }
128
+ if(count($productSkus)==0){
129
+ $this->_fault('no_products_assigned_to_category');
130
+ }
131
+ $conditions = $this->setConditions("sku", $productSkus);
132
+
133
+ $cus_groups = array();
134
+ if($cus_group = $this->getGroup($mamutCustomerId)){
135
+ $cus_groups[] = $cus_group;
136
+ }else{
137
+ $cus_groups[] = 1;
138
+ }
139
+
140
+ $rule_id = $this->createRule($data, $cus_groups , null, 1, $conditions);
141
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutCustomerId);
142
+
143
+ return $rule_id;
144
+ }
145
+
146
+ public function checkCreateFixedPriceForCustomerGroup($mamutRuleId, $customerGroup, $productSku, $price){
147
+ $rule_id = 0;
148
+ $data = array(
149
+ 'name' => 'Rule for customer group: '.$customerGroup.' fixed Price '.$price,
150
+ 'is_active' => '1',
151
+ 'simple_action' => 'to_fixed',
152
+ 'discount_amount' => $price,
153
+ );
154
+ $conditions = $this->setConditions("sku", $productSku);
155
+
156
+ $customerGroupId = $this->getCustomerGroups($customerGroup);
157
+
158
+ if(!$customerGroupId){
159
+ $this->_fault('customer_group_not_exists');
160
+ }
161
+ $rule_id = $this->createRule($data, array($customerGroupId), null, 1, $conditions);
162
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, null);
163
+
164
+ return $rule_id;
165
+ }
166
+
167
+ public function checkCreateDiscountForCustomerGroup($mamutRuleId, $customerGroup, $productSku, $discountPercentage){
168
+ $rule_id = 0;
169
+ $data = array(
170
+ 'name' => 'Rule for customer group: '.$customerGroup.' discount percentage '.$discountPercentage,
171
+ 'is_active' => '1',
172
+ 'simple_action' => 'by_percent',
173
+ 'discount_amount' => $discountPercentage,
174
+ );
175
+ $conditions = $this->setConditions("sku", $productSku);
176
+
177
+ $customerGroupId = $this->getCustomerGroups($customerGroup);
178
+
179
+ if(!$customerGroupId){
180
+ $this->_fault('customer_group_not_exists');
181
+ }
182
+ $rule_id = $this->createRule($data, array($customerGroupId), null, 1, $conditions);
183
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, null);
184
+
185
+ return $rule_id;
186
+ }
187
+
188
+ public function checkCreateDiscountCategoryForCustomerGroup($mamutRuleId, $customerGroup, $categoryId, $discountPercentage){
189
+
190
+ /*
191
+ $rule_id = 0;
192
+ $data = array(
193
+ 'name' => 'Rule for customer group on category: '.$customerGroup.' discount percentage '.$discountPercentage,
194
+ 'is_active' => '1',
195
+ 'simple_action' => 'by_percent',
196
+ 'discount_amount' => $discountPercentage,
197
+ );
198
+ $conditions = $this->setConditions("category_ids", $categoryId);
199
+
200
+ $customerGroupId = $this->getCustomerGroups($customerGroup);
201
+
202
+ if(!$customerGroupId){
203
+ $this->_fault('customer_group_not_exists');
204
+ }
205
+ $rule_id = $this->createRule($data, array($customerGroupId), null, 1, $conditions);
206
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, null);
207
+
208
+ return $rule_id;*/
209
+
210
+ $rule_id = 0;
211
+ $data = array(
212
+ 'name' => 'Rule for customer group on category: '.$customerGroup.' discount percentage '.$discountPercentage,
213
+ 'is_active' => '1',
214
+ 'simple_action' => 'by_percent',
215
+ 'discount_amount' => $discountPercentage,
216
+ );
217
+ $productSkus = array();
218
+ $category = Mage::getModel('catalog/category')->load($categoryId);
219
+ $productCollection = $category->getProductCollection();
220
+
221
+ foreach ($productCollection as $product){
222
+ $productSkus[] = $product->getSku();
223
+ }
224
+ if(count($productSkus)==0){
225
+ $this->_fault('no_products_assigned_to_category');
226
+ }
227
+ $conditions = $this->setConditions("sku", $productSkus);
228
+
229
+ $customerGroupId = $this->getCustomerGroups($customerGroup);
230
+
231
+ if(!$customerGroupId){
232
+ $this->_fault('customer_group_not_exists');
233
+ }
234
+ $rule_id = $this->createRule($data, array($customerGroupId), null, 1, $conditions);
235
+ $this->mapRuleToMamutRule($rule_id, $mamutRuleId, null);
236
+
237
+ return $rule_id;
238
+
239
+ }
240
+
241
+ public function deleteDiscountRule($mamutRuleIds){
242
+
243
+ if(count ($mamutRuleIds) == 0){
244
+ $this->_fault('array_not_pased');
245
+ }
246
+
247
+ $resource = Mage::getSingleton('core/resource');
248
+ $connection = $resource->getConnection('core_write');
249
+
250
+ $mamut_to_rule_table = $resource->getTableName('ecomwise_catalogpromotions_mapping');
251
+
252
+ $result_rules = $connection->query("select * from ".$mamut_to_rule_table." ");
253
+
254
+ $rows = $result_rules->fetchAll(PDO::FETCH_ASSOC);
255
+
256
+ $deleted = false;
257
+ foreach($rows as $row){
258
+ $rule_mamut_id = $row['mamut_rule_id'] ;
259
+ if(!in_array($rule_mamut_id, $mamutRuleIds)){
260
+
261
+ $result_rule = $connection->fetchRow("select rule_id from ".$mamut_to_rule_table."
262
+ where mamut_rule_id=?", $rule_mamut_id);
263
+
264
+ if($result_rule['rule_id'] != null){
265
+ $rule = Mage::getModel('catalogrule/rule')->load($result_rule['rule_id']);
266
+ $rule->delete();
267
+ $connection->delete($mamut_to_rule_table, 'mamut_rule_id = ' . $rule_mamut_id);
268
+ $deleted = true;
269
+ }
270
+ }
271
+ }
272
+ return $deleted;
273
+ }
274
+
275
+ public function createRule($ruleData = null, $customerGroupIds=null, $websitesIds=null, $applyRule = null, $conditions = null){
276
+ $data = array(
277
+ 'name' => 'api_rule',
278
+ 'description' => '',
279
+ 'from_date' => '',
280
+ 'to_date' => '',
281
+ 'is_active' => '1',
282
+ 'conditions_serialized' => '',
283
+ 'actions_serialized' => '',
284
+ 'stop_rules_processing' => '0',
285
+ 'sort_order' => '0',
286
+ 'simple_action' => 'by_fixed',
287
+ 'discount_amount' => '0',
288
+ );
289
+
290
+ if($ruleData === null){
291
+ $ruleData = array();
292
+ }
293
+
294
+ foreach($ruleData as $key => $newValue)
295
+ if(isset($data[$key]) == false){
296
+ $this->_fault('code_not_valid');
297
+ }else{
298
+ $data[$key] = $newValue;
299
+ }
300
+
301
+ if($customerGroupIds){
302
+ if(is_array($customerGroupIds)){
303
+ foreach($customerGroupIds as $groupid){
304
+ $group = Mage::getModel('customer/group')->load($groupid);
305
+ if(!($group->getId())){
306
+ return $this->_fault('customer_group_not_exists');
307
+ }
308
+ }
309
+ $data['customer_group_ids'] = $customerGroupIds;
310
+ }else{
311
+ return $this->_fault('customerids_array_not_passed');
312
+ }
313
+ }else{
314
+ $data['customer_group_ids']= array(1);
315
+ }
316
+
317
+ if($websitesIds){
318
+ if(is_array($websitesIds)){
319
+ foreach($websitesIds as $webid){
320
+ $web = Mage::app()->getWebsite($webid);
321
+ if(!$web){
322
+ return $this->_fault('website_not_exists');
323
+ }
324
+ }
325
+ $data['website_ids'] = $websitesIds;
326
+ }else{
327
+ return $this->_fault('websiteids_array_not_passed');
328
+ }
329
+ }else{
330
+ $wids = array();
331
+ foreach (Mage::app()->getWebsites() as $website) {
332
+ $websiteId = $website->getId();
333
+ $wids[] = $websiteId;
334
+ }
335
+ $data['website_ids'] = $wids;
336
+ }
337
+
338
+ try{
339
+
340
+ $rule = Mage::getModel('catalogrule/rule');
341
+ $rule->setData($data);
342
+
343
+ foreach($conditions as $condition){
344
+ $rule->getConditions()->addCondition($condition);
345
+ }
346
+ $rule->save();
347
+
348
+ return $rule->getId();
349
+ }catch(Mage_Core_Exception $e){
350
+ return $this->_fault('not_created',$e->getMessage());
351
+ }
352
+
353
+ }
354
+
355
+
356
+ private function isIndInstalled(){
357
+ $modules = Mage::getConfig()->getNode('modules')->children();
358
+ $modulesArray = (array)$modules;
359
+
360
+ if(isset($modulesArray['Ecomwise_Customerpromotions'])) {
361
+
362
+ return true;
363
+ } else {
364
+ return false;
365
+ }
366
+
367
+ }
368
+
369
+ private function mapRuleToMamutRule($rule_id, $mamutRuleId, $mamutcustomerid = null){
370
+
371
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
372
+
373
+ $resurce = Mage::getSingleton('core/resource');
374
+ $mamut_to_rule_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
375
+
376
+ $mamut_id = ($mamutcustomerid != null)? $mamutcustomerid : 0;
377
+
378
+
379
+ $result_rule = $connection->fetchRow("select rule_id from ".$mamut_to_rule_table."
380
+ where mamut_rule_id=?", array($mamutRuleId));
381
+
382
+ if($result_rule['rule_id'] != null){
383
+ $rule = Mage::getModel('catalogrule/rule')->load($result_rule['rule_id']);
384
+ $rule->delete();
385
+
386
+ }
387
+
388
+
389
+ $connection->delete($mamut_to_rule_table, 'mamut_rule_id = ' . $mamutRuleId);
390
+
391
+
392
+ $data = array('rule_id'=> $rule_id,'mamut_id'=> $mamut_id,'mamut_rule_id'=>$mamutRuleId);
393
+ $connection->insert($mamut_to_rule_table , $data);
394
+ return;
395
+
396
+ }
397
+ private function getCustomerGroups($customerGroup){
398
+ $model = Mage::getModel('mshopb2b/catalogpromotions');
399
+ $customer_groups = $model->get_customer_groups();
400
+ foreach($customer_groups as $key=>$val){
401
+ if($val == $customerGroup){
402
+ return $key;
403
+ }
404
+
405
+ }
406
+ return false;
407
+ }
408
+
409
+ private function getGroup($mamut_customer_id){
410
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
411
+
412
+ $resurce = Mage::getSingleton('core/resource');
413
+ $mapping_table = $resurce->getTableName('ecomwise_customermamut_mapping');
414
+ $query = $connection ->select()
415
+ ->from($mapping_table, array('customer_id'))
416
+ ->where('mamut_id = ?', $mamut_customer_id)
417
+ ->limit(1);
418
+ $row_mamut = $connection->fetchRow($query);
419
+ if($row_mamut){
420
+ $cusomer_id = $row_mamut['customer_id'];
421
+ $customer = Mage::getModel('customer/customer')->load($cusomer_id);
422
+ if($customer->getId()!= null){
423
+ return $customer->getGroupId();
424
+
425
+ }else{
426
+ return false;
427
+ }
428
+ }else{
429
+
430
+ return false;
431
+ }
432
+
433
+ }
434
+
435
+ private function setConditions($type, $params){
436
+
437
+ $conditions = array();
438
+ if(is_array($params)){
439
+ foreach ($params as $param){
440
+ $skuCondition = Mage::getModel('catalogrule/rule_condition_product')
441
+ ->setType('catalogrule/rule_condition_product')
442
+ ->setAttribute($type)
443
+ ->setOperator('==')
444
+ ->setValue($param);
445
+ $conditions[] = $skuCondition;
446
+ }
447
+ }else{
448
+ $skuCondition = Mage::getModel('catalogrule/rule_condition_product')
449
+ ->setType('catalogrule/rule_condition_product')
450
+ ->setAttribute($type)
451
+ ->setOperator('==')
452
+ ->setValue($params);
453
+ $conditions[] = $skuCondition;
454
+ }
455
+ return $conditions;
456
+ }
457
+
458
+ private function changeAggregationToAny($rule_id){
459
+ $rule = Mage::getModel('catalogrule/rule')->load($rule_id);
460
+ $cond = unserialize($rule->getConditionsSerialized() );
461
+ $cond['aggregator'] = 'any';
462
+
463
+ $resource = Mage::getSingleton('core/resource');
464
+ $writer = $resource->getConnection('core_write');
465
+
466
+ $sql = "UPDATE ".$resource->getTableName('catalogrule')." SET conditions_serialized=? WHERE rule_id=\"".$rule_id."\"";
467
+ $writer->query($sql, serialize($cond));
468
+ }
469
+
470
+ private function createDiscountForCustomer($mamutRuleId, $mamutCustomerId, $productSku, $discountPercentage){
471
+ $rule_id = 0;
472
+ $session_parameter = $mamutRuleId."-".$mamutCustomerId."-".$productSku."-".$discountPercentage;
473
+
474
+ $data = array(
475
+ 'name' => 'Rule: '.$mamutRuleId.' for mamut user: '.$mamutCustomerId.' discount percentage '.$discountPercentage,
476
+ 'is_active' => '1',
477
+ 'simple_action' => 'by_percent',
478
+ 'discount_amount' => $discountPercentage,
479
+ );
480
+
481
+ $conditions = $this->setConditions("sku", $productSku);
482
+
483
+ $cus_groups = array();
484
+ if($cus_group = $this->getGroup($mamutCustomerId)){
485
+ $cus_groups[] = $cus_group;
486
+ }else{
487
+ $cus_groups[] = 1;
488
+ }
489
+
490
+ $rule_id = $this->createRule($data, $cus_groups, null, 1, $conditions);
491
+ $this->mapMultipleMamutRuleForMamutCustomer($rule_id, $mamutRuleId, $mamutCustomerId);
492
+
493
+ return $rule_id;
494
+ }
495
+
496
+ private function mapMultipleMamutRuleForMamutCustomer($rule_id, $mamutRuleId, $mamutcustomerid = null){
497
+
498
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
499
+
500
+ $resurce = Mage::getSingleton('core/resource');
501
+ $mamut_to_rule_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
502
+
503
+ $mamut_id = ($mamutcustomerid != null)? $mamutcustomerid : 0;
504
+
505
+ $data = array('rule_id'=> $rule_id,'mamut_id'=> $mamut_id,'mamut_rule_id'=>$mamutRuleId);
506
+ $connection->insert($mamut_to_rule_table , $data);
507
+ return;
508
+
509
+ }
510
+
511
+ public function applyRules(){
512
+ try{
513
+ $resource = Mage::getResourceSingleton('catalogrule/rule');
514
+ $collection = Mage::getModel("catalogrule/rule")->getCollection();
515
+ $collection->walk(array($resource, 'updateRuleProductData'));
516
+ $resource->applyAllRulesForDateRange();
517
+ Mage::app()->removeCache('catalog_rules_dirty');
518
+ return true;
519
+ }catch(Exception $ex){
520
+ Mage::log($ex->getMessage());
521
+ return false;
522
+ }
523
+ }
524
+
525
+ }
app/code/community/Ecomwise/MshopB2B/Model/Api/Promotions/Api/V2.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_MshopB2B_Model_Api_Promotions_Api_V2 extends Ecomwise_MshopB2B_Model_Api_Promotions_Api
4
+ {
5
+
6
+ }
app/code/community/Ecomwise/MshopB2B/Model/Carrier/Mamutshipping.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_Mshopb2b_Model_Carrier_Mamutshipping
3
+ extends Mage_Shipping_Model_Carrier_Abstract
4
+ implements Mage_Shipping_Model_Carrier_Interface
5
+ {
6
+ protected $_code = 'mamut_shipping';
7
+ protected $_isFixed = false;
8
+
9
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
10
+ {
11
+
12
+ if (!(Mage::app()->getStore()->isAdmin())) {
13
+ return;
14
+ }
15
+
16
+
17
+ $result = Mage::getModel('shipping/rate_result');
18
+
19
+ $method = Mage::getModel('shipping/rate_result_method');
20
+ $method->setCarrier('mamut_shipping');
21
+ $method->setCarrierTitle($this->getConfigData('title'));
22
+ $method->setMethod('mamut_shipping');
23
+ $method->setMethodTitle($this->getConfigData('name'));
24
+
25
+
26
+
27
+ $method->setPrice(0);
28
+ $method->setCost(0);
29
+
30
+ $result->append($method);
31
+
32
+ return $result;
33
+ }
34
+
35
+ public function getAllowedMethods()
36
+ {
37
+ return array('mamut_shipping' => $this->getConfigData('name'));
38
+ }
39
+ }
app/code/community/Ecomwise/MshopB2B/Model/Catalogpromotions.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_MshopB2B_Model_Catalogpromotions extends Mage_Eav_Model_Entity_Attribute{
4
+
5
+ public function get_customer_groups(){
6
+
7
+ $notlogged = false;
8
+
9
+ $customer_groups = Mage::getResourceModel('customer/group_collection')
10
+ ->load()->toOptionArray();
11
+
12
+
13
+ foreach ($customer_groups as $group) {
14
+ if ($group['value']==0) {
15
+ $notlogged = true;
16
+ }
17
+ }
18
+ if (!$notlogged) {
19
+ array_unshift($customer_groups, array('value'=>0, 'label'=>Mage::helper('salesrule')->__('NOT LOGGED IN')));
20
+ }
21
+
22
+
23
+ $customer_groups_array = array();
24
+
25
+ if ($customer_groups){
26
+ foreach ($customer_groups as $group){
27
+ $customer_groups_array[$group['value']] = $group['label'];
28
+ }
29
+ }
30
+
31
+ return $customer_groups_array;
32
+ }
33
+
34
+ public function get_customers(){
35
+
36
+ $customers = array();
37
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
38
+ $resurce = Mage::getSingleton('core/resource');
39
+ $customer_to_rule_table = $resurce->getTableName('ecomwise_customermamut_mapping');
40
+
41
+
42
+
43
+ $query = $connection ->select()
44
+ ->from($customer_to_rule_table, array('customer_id'))
45
+ ->group('customer_id');
46
+
47
+ $customer_rows = $connection->fetchCol($query);
48
+
49
+ if ($customer_rows) {
50
+ $customer_collection = Mage::getResourceModel('customer/customer_collection')
51
+ ->addNameToSelect()
52
+ ->addAttributeToFilter('entity_id', $customer_rows)
53
+ ->load();
54
+
55
+ foreach ($customer_collection as $customer){
56
+ $name = $customer->getName() . ' - ' . $customer->getEmail();
57
+ $customers[$customer->getId()] = $name;
58
+ }
59
+ }
60
+
61
+ return $customers;
62
+
63
+ }
64
+
65
+ public function getMamutId($rule_id = null){
66
+ if($rule_id != null){
67
+ $resurce = Mage::getSingleton('core/resource');
68
+ $mapping_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
69
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
70
+
71
+ $result = $connection->query('SELECT * FROM '.$mapping_table.'
72
+ WHERE rule_id = '.$rule_id.'
73
+ LIMIT 1');
74
+ $row = $result->fetch(PDO::FETCH_ASSOC);
75
+
76
+ if($row){
77
+ return $row['mamut_id'];
78
+ }else{
79
+ return false;
80
+ }
81
+
82
+ }else{
83
+ return false;
84
+ }
85
+
86
+ }
87
+
88
+
89
+ }
app/code/community/Ecomwise/MshopB2B/Model/Collections/RuleCollection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Collections_RuleCollection extends Mage_CatalogRule_Model_Resource_Rule_Collection{
3
+ public function getSelectCountSql()
4
+ {
5
+ $this->_renderFilters();
6
+ $countSelect = clone $this->getSelect();
7
+ $countSelect->reset(Zend_Db_Select::ORDER);
8
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
9
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
10
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
11
+ if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
12
+ $countSelect->reset(Zend_Db_Select::GROUP);
13
+ $countSelect->distinct(true);
14
+ $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
15
+ $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
16
+ } else {
17
+ $countSelect->columns('COUNT(*)');
18
+ }
19
+ return $countSelect;
20
+ }
21
+ }
app/code/community/Ecomwise/MshopB2B/Model/Customer/Group.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Customer_Group extends Mage_Customer_Model_Group{
3
+
4
+ protected function _prepareData()
5
+ {
6
+ $this->setCode(
7
+ substr($this->getCode(), 0, 100)
8
+ );
9
+ return $this;
10
+ }
11
+
12
+
13
+ }
app/code/community/Ecomwise/MshopB2B/Model/Customerattribute/Backend/Mamutgroups.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Customerattribute_Backend_Mamutgroups extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
3
+ {
4
+
5
+ public function validate($object)
6
+ {
7
+ $attributeCode = $this->getAttribute()->getName();
8
+ $postDataConfig = ($object->getData('use_post_data_config'))? $object->getData('use_post_data_config') : array();
9
+
10
+ $isUseConfig = false;
11
+ if ($postDataConfig) {
12
+ $isUseConfig = in_array($attributeCode, $postDataConfig);
13
+ }
14
+
15
+ if ($this->getAttribute()->getIsRequired()) {
16
+ $attributeValue = $object->getData($attributeCode);
17
+ if ($this->getAttribute()->isValueEmpty($attributeValue)) {
18
+ if (is_array($attributeValue) && count($attributeValue)>0) {
19
+ } else {
20
+ if(!$isUseConfig) {
21
+ return false;
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ if ($this->getAttribute()->getIsUnique()) {
28
+ if (!$this->getAttribute()->getEntity()->checkAttributeUniqueValue($this->getAttribute(), $object)) {
29
+ $label = $this->getAttribute()->getFrontend()->getLabel();
30
+ Mage::throwException(Mage::helper('eav')->__('The value of attribute "%s" must be unique.', $label));
31
+ }
32
+ }
33
+
34
+
35
+ return true;
36
+ }
37
+
38
+ /**
39
+ * Before Attribute Save Process
40
+ *
41
+ * @param Varien_Object $object
42
+ * @return Mage_Catalog_Model_Category_Attribute_Backend_Sortby
43
+ */
44
+ public function beforeSave($object) {
45
+
46
+
47
+ $attributeCode = $this->getAttribute()->getName();
48
+ if (is_null($object->getData($attributeCode))) {
49
+ $object->setData($attributeCode, false);
50
+ }
51
+ return $this;
52
+ }
53
+
54
+ public function afterLoad($object) {
55
+ $attributeCode = $this->getAttribute()->getName();
56
+ if ($attributeCode == 'mamut_contact_groups') {
57
+ $data = $object->getData($attributeCode);
58
+ if ($data) {
59
+ $object->setData($attributeCode, explode(',', $data));
60
+ }
61
+ }
62
+ return $this;
63
+ }
64
+ }
app/code/community/Ecomwise/MshopB2B/Model/Customerattribute/Source/Mamutgroups.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Customerattribute_Source_Mamutgroups extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
3
+ {
4
+ public function getAllOptions()
5
+ {
6
+ if (!$this->_options) {
7
+
8
+ $resource = Mage::getSingleton('core/resource');
9
+ $reader = $resource->getConnection('core_read');
10
+ $tablename = $resource->gettableName('ecomwise_mamut_contact_groups');
11
+
12
+ $rows = $reader->fetchAll("SELECT * FROM ".$tablename." WHERE mamut_contact_group_name !='MAMUT NOT LOGGED IN'");
13
+ if($rows){
14
+ foreach ($rows as $row){
15
+ $this->_options[] = array(
16
+ 'label' => $row['mamut_contact_group_name'],
17
+ 'value' => $row['mamut_contact_group_name'],
18
+ 'selected' => true,
19
+ );
20
+ }
21
+ }else{
22
+ $this->_options[] = array(
23
+ 'label' => "There are no mamut contact groups uploaded",
24
+ 'value' => "0",
25
+ 'selected' => true,
26
+ );
27
+ }
28
+
29
+ }
30
+ return $this->_options;
31
+ }
32
+ }
app/code/community/Ecomwise/MshopB2B/Model/Observer.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Observer extends Varien_Object{
3
+
4
+ /**
5
+ *
6
+ * Event listener for "catalog_product_collection_load_after"
7
+ * It applies individual price rules to a product colection calculating them on run instead taking from database
8
+ *
9
+ */
10
+ public function prepareCollection($observer){
11
+ $data = $observer->getCollection();
12
+ $customer_group = Mage::getSingleton('customer/session')->getCustomerGroupId();
13
+ $storeId = Mage::app()->getStore()->getId();
14
+ $webid = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
15
+
16
+ foreach ($data as $product) {
17
+
18
+ if($product->getTypeId() == "bundle"){
19
+
20
+ $product->setMinPrice(null);
21
+ $product->setMaxPrice(null);
22
+
23
+ }else if($product->getTypeId() == "grouped"){
24
+
25
+ $assoc_products = $product->getTypeInstance(true)->getAssociatedProductIds($product);
26
+ $assoc_prices = Mage::getResourceModel('catalogrule/rule')->getRulePrices(date("Y-m-d"), $webid, $customer_group, $assoc_products);
27
+ $product->setMinimalPrice(min($assoc_prices));
28
+ }else{
29
+
30
+ $final_price = Mage::getResourceModel('catalogrule/rule')
31
+ ->getRulePrice(date("Y-m-d"),$webid,$customer_group,$product->getId());
32
+
33
+
34
+ if($final_price){
35
+ $minimalPrice = $product->getMinimalPrice();
36
+ $price = $product->getPrice();
37
+
38
+ if($final_price < $price){
39
+ $product->setFinalPrice($final_price);
40
+ }
41
+
42
+ if($final_price < $minimalPrice){
43
+ $product->setMinimalPrice($final_price);
44
+ }
45
+ //$product->setFinalPrice($final_price);
46
+ //$product->setMinimalPrice($final_price);
47
+ //$product->setMaximalPrice($final_price);
48
+ }
49
+
50
+
51
+ }
52
+
53
+ }
54
+
55
+ return;
56
+ }
57
+
58
+ /**
59
+ *
60
+ * Event listener for "catalogrule_rule_delete_after". Delete individula customer mappings for rule
61
+ * @ Object $observer
62
+ */
63
+ public function afterDeleteRule($observer){
64
+
65
+
66
+ $data = $observer->getData();
67
+ $rule = $data['data_object'];
68
+ $rule_id = $rule -> getId();
69
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
70
+
71
+ $resurce = Mage::getSingleton('core/resource');
72
+ $customer_to_rule_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
73
+
74
+ $connection->delete($customer_to_rule_table, 'rule_id = ' . $rule_id);
75
+
76
+ return;
77
+
78
+ }
79
+
80
+ }
app/code/community/Ecomwise/MshopB2B/Model/Payment/Mamutbilling.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecomwise_Mshopb2b_Model_Payment_Mamutbilling extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+
6
+ protected $_code = 'mamut_billing';
7
+
8
+ protected $_isInitializeNeeded = true;
9
+ protected $_canUseInternal = false;
10
+ protected $_canUseForMultishipping = false;
11
+ protected $_canUseCheckout = false;
12
+
13
+ }
app/code/community/Ecomwise/MshopB2B/Model/Rules/CatalogRule.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Rules_CatalogRule extends Mage_CatalogRule_Model_Rule{
3
+
4
+ /**
5
+ *
6
+ * Function calculates price rules for product. It get all rules for
7
+ * product and calculates its price.
8
+ * It is used by configurable products
9
+ * @see Mage_CatalogRule_Model_Rule::calcProductPriceRule()
10
+ */
11
+
12
+ public function calcProductPriceRule(Mage_Catalog_Model_Product $product, $price){
13
+ $priceRules = null;
14
+ $productId = $product->getId();
15
+ $storeId = $product->getStoreId();
16
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
17
+ $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
18
+ $dateTs = Mage::app()->getLocale()->storeTimeStamp($storeId);
19
+ $cacheKey = date('Y-m-d', $dateTs)."|$websiteId|$customerGroupId|$productId|$price";
20
+ $customer_id = Mage::getSingleton('customer/session')->getCustomerId();
21
+ if($customer_id == null){
22
+ if ($_SESSION && isset($_SESSION['adminhtml_quote']) && isset($_SESSION['adminhtml_quote']['customer_id']) && $_SESSION['adminhtml_quote']['customer_id'])
23
+ {
24
+ $customer_id = $_SESSION['adminhtml_quote']['customer_id'];
25
+ }
26
+
27
+ }
28
+ $rule_ids = Mage::helper("mshopb2b")-> getRulesForCustomer($customer_id);
29
+
30
+ $product_rule_data = $this->getResource()->_getRuleProductsStmt($time, $time, $productId, $websiteId)->fetchAll();
31
+ //filter hihest discount rule for customer
32
+ $product_rule_data =Mage::getResourceModel('catalogrule/rule')->filterIndividual($product_rule_data, $rule_ids, $customer_id , $price, $customerGroupId);
33
+
34
+ $priceRules = $price;
35
+ $ind_rules = array();
36
+ foreach ($product_rule_data as $data){
37
+ $rule_id = $data['rule_id'];
38
+ if(!in_array($rule_id, $ind_rules)){
39
+ $priceRules = Mage::helper('catalogrule')->calcPriceRule(
40
+ $data['action_operator'],
41
+ $data['action_amount'],
42
+ $priceRules );
43
+ $ind_rules[] = $rule_id;
44
+ if ($data['action_stop']) {
45
+ break;
46
+ }
47
+ }
48
+ }
49
+
50
+ return $priceRules;
51
+ }
52
+
53
+
54
+
55
+ }
app/code/community/Ecomwise/MshopB2B/Model/Rules/Combine.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class extends and overwrites Mage_CatalogRule_Model_Rule_Condition_Combine
4
+ * constructor setting the default aggregator to ANY
5
+ *
6
+ *
7
+ * @author
8
+ *
9
+ */
10
+ class Ecomwise_MshopB2B_Model_Rules_Combine extends Mage_CatalogRule_Model_Rule_Condition_Combine{
11
+
12
+ public function __construct(){
13
+ parent::__construct();
14
+ $this->setType('catalogrule/rule_condition_combine')
15
+ ->setAggregator('any');
16
+ }
17
+ }
app/code/community/Ecomwise/MshopB2B/Model/Rules/MySQL4Rule.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Rules_MySQL4Rule extends Mage_CatalogRule_Model_Mysql4_Rule{
3
+
4
+ public function getRulePrice($date, $wId, $gId, $pId){
5
+
6
+ $data = $this->getRulePrices($date, $wId, $gId, array($pId));
7
+
8
+ if (isset($data[$pId])) {
9
+ return $data[$pId];
10
+ }
11
+
12
+ return false;
13
+ }
14
+ /**
15
+ *
16
+ * Main function that calculates catalog rules prices for group of products
17
+ * Selects all rules that are applied to that product for given date,
18
+ * and applyies rules to the product price depending on the customer, customer group
19
+ * @see Mage_CatalogRule_Model_Mysql4_Rule::getRulePrices()
20
+ */
21
+ public function getRulePrices($date, $websiteId, $customerGroupId, $productIds){
22
+
23
+ $customer_id = Mage::getSingleton('customer/session')->getCustomerId();
24
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
25
+
26
+ $resurce = Mage::getSingleton('core/resource');
27
+ $mapping_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
28
+
29
+ $rule_prices = $resurce->getTableName('catalogrule_product_price');
30
+ $rule_product = $resurce->getTableName('catalogrule_product');
31
+
32
+ if($mapping_table != null){
33
+ if($customer_id == null){
34
+ if ($_SESSION && isset($_SESSION['adminhtml_quote']) && isset($_SESSION['adminhtml_quote']['customer_id']) && $_SESSION['adminhtml_quote']['customer_id']){
35
+ $customer_id = $_SESSION['adminhtml_quote']['customer_id'];
36
+ }
37
+
38
+ }
39
+
40
+ }
41
+
42
+ $rule_ids = Mage::helper("mshopb2b") -> getRulesForCustomer($customer_id);
43
+
44
+ $adapter = $this->_getReadAdapter();
45
+
46
+ $product_prices = array();
47
+ foreach ($productIds as $pid){
48
+
49
+ $time = strtotime($date);
50
+
51
+ $product_rule_data = $this->_getRuleProductsStmt($time, $time, $pid, $websiteId)->fetchAll();
52
+
53
+ if($product_rule_data){
54
+ $websiteId = $product_rule_data[0]['website_id'];
55
+ if (isset($product_rule_data[0]['website_'.$websiteId.'_price'])) {
56
+ $productPrice = $product_rule_data[0]['website_'.$websiteId.'_price'];
57
+ }else {
58
+ $productPrice = $product_rule_data[0]['default_price'];
59
+ }
60
+ }else{
61
+ $storeId = Mage::app()->getStore()->getId();
62
+ $product = Mage::getModel('catalog/product')
63
+ ->setStoreId($storeId)
64
+ ->load($pid);
65
+ $productPrice = $product->getPrice();
66
+ }
67
+
68
+ //filter hihest discount rule for customer
69
+ $product_rule_data = $this->filterIndividual($product_rule_data, $rule_ids, $customer_id , $productPrice, $customerGroupId);
70
+
71
+ $priceRules = $productPrice;
72
+ $ind_rules = array();
73
+ foreach ($product_rule_data as $data){
74
+ $rule_id = $data['rule_id'];
75
+ if(!in_array($rule_id, $ind_rules)){
76
+ $priceRules = Mage::helper('catalogrule')->calcPriceRule(
77
+ $data['action_operator'],
78
+ $data['action_amount'],
79
+ $priceRules );
80
+ $ind_rules[] = $rule_id;
81
+ if ($data['action_stop']) {
82
+ break;
83
+ }
84
+ }
85
+ }
86
+ $priceRules = Mage::app()->getStore()->roundPrice($priceRules);
87
+ $product_prices[$pid] = $priceRules;
88
+
89
+ }
90
+
91
+ return $product_prices;
92
+ }
93
+ /**
94
+ *
95
+ *
96
+ * Checks if the rule is for individual customer
97
+ * @param unknown_type $rule_id
98
+ * @param unknown_type $customerId
99
+ */
100
+ protected function isInd($rule_id, $customerId){
101
+
102
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
103
+
104
+ $resurce = Mage::getSingleton('core/resource');
105
+ $mapping_table = $resurce->getTableName('ecomwise_catalogpromotions_mapping');
106
+
107
+ $query = $connection ->select()
108
+ ->from($mapping_table)
109
+ ->where('rule_id = ?', $rule_id);
110
+
111
+ $rule_rows = $connection->fetchRow($query);
112
+
113
+ if($rule_rows and $rule_rows['mamut_id'] != 0){
114
+
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+
120
+ /**
121
+ *
122
+ * Core magento function that selects all rules for product for given date.
123
+ *
124
+ * @see Mage_CatalogRule_Model_Mysql4_Rule::_getRuleProductsStmt()
125
+ */
126
+
127
+ public function _getRuleProductsStmt($fromDate, $toDate, $productId=null, $websiteId = null)
128
+ {
129
+ $read = $this->_getReadAdapter();
130
+ /**
131
+ * Sort order is important
132
+ * It used for check stop price rule condition.
133
+ * website_id customer_group_id product_id sort_order
134
+ * 1 1 1 0
135
+ * 1 1 1 1
136
+ * 1 1 1 2
137
+ * if row with sort order 1 will have stop flag we should exclude
138
+ * all next rows for same product id from price calculation
139
+ */
140
+ $select = $read->select()
141
+ ->from(array('rp'=>$this->getTable('catalogrule/rule_product')))
142
+ ->where($read->quoteInto('rp.from_time=0 or rp.from_time<=?', $toDate)
143
+ ." or ".$read->quoteInto('rp.to_time=0 or rp.to_time>=?', $fromDate))
144
+
145
+ ->order(array('rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id'));
146
+
147
+ if (!is_null($productId)) {
148
+ $select->where('rp.product_id=?', $productId);
149
+ }
150
+
151
+ /**
152
+ * Join default price and websites prices to result
153
+ */
154
+ $priceAttr = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'price');
155
+ $priceTable = $priceAttr->getBackend()->getTable();
156
+ $attributeId= $priceAttr->getId();
157
+
158
+ $joinCondition = '%1$s.entity_id=rp.product_id AND (%1$s.attribute_id='.$attributeId.') and %1$s.store_id=%2$s';
159
+
160
+ $select->join(
161
+ array('pp_default'=>$priceTable),
162
+ sprintf($joinCondition, 'pp_default', Mage_Core_Model_App::ADMIN_STORE_ID),
163
+ array('default_price'=>'pp_default.value')
164
+ );
165
+
166
+ if ($websiteId !== null) {
167
+ $website = Mage::app()->getWebsite($websiteId);
168
+ $defaultGroup = $website->getDefaultGroup();
169
+ if ($defaultGroup instanceof Mage_Core_Model_Store_Group) {
170
+ $storeId = $defaultGroup->getDefaultStoreId();
171
+ } else {
172
+ $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
173
+ }
174
+
175
+ $select->joinInner(
176
+ array('product_website'=>$this->getTable('catalog/product_website')),
177
+ 'product_website.product_id=rp.product_id AND rp.website_id=product_website.website_id AND product_website.website_id='.$websiteId,
178
+ array()
179
+ );
180
+
181
+ $tableAlias = 'pp'.$websiteId;
182
+ $fieldAlias = 'website_'.$websiteId.'_price';
183
+ $select->joinLeft(
184
+ array($tableAlias=>$priceTable),
185
+ sprintf($joinCondition, $tableAlias, $storeId),
186
+ array($fieldAlias=>$tableAlias.'.value')
187
+ );
188
+ } else {
189
+ foreach (Mage::app()->getWebsites() as $website) {
190
+ $websiteId = $website->getId();
191
+ $defaultGroup = $website->getDefaultGroup();
192
+ if ($defaultGroup instanceof Mage_Core_Model_Store_Group) {
193
+ $storeId = $defaultGroup->getDefaultStoreId();
194
+ } else {
195
+ $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
196
+ }
197
+
198
+ $storeId = $defaultGroup->getDefaultStoreId();
199
+ $tableAlias = 'pp'.$websiteId;
200
+ $fieldAlias = 'website_'.$websiteId.'_price';
201
+ $select->joinLeft(
202
+ array($tableAlias=>$priceTable),
203
+ sprintf($joinCondition, $tableAlias, $storeId),
204
+ array($fieldAlias=>$tableAlias.'.value')
205
+ );
206
+ }
207
+ }
208
+ return $read->query($select);
209
+ }
210
+
211
+
212
+ public function filterIndividual($product_rule_data, $rule_ids, $customer_id, $productPrice, $customerGroupId){
213
+ //containers for highest discount rule id and discout price
214
+ $highest = null;
215
+ $price_start = 100000000000;
216
+
217
+
218
+ $individual = array();
219
+
220
+ foreach($product_rule_data as $key => $data ){
221
+
222
+ //if rule is for other individual customer is removed
223
+ if($this->isInd($data['rule_id'], $customer_id)){
224
+ if(!in_array($data['rule_id'], $rule_ids)){
225
+ unset($product_rule_data[$key]);
226
+ }else{
227
+ //rule price is calculated for later filtering, and if highes, rule_id is stored in $hihgest.
228
+ $rule_price = Mage::helper('catalogrule')->calcPriceRule(
229
+ $data['action_operator'],
230
+ $data['action_amount'],
231
+ $productPrice);
232
+ if($rule_price < $price_start){
233
+ $price_start = $rule_price;
234
+ $highest = $key;
235
+ }
236
+ //used for later filtering of highest discount rule
237
+ $individual[] = $key;
238
+ }
239
+
240
+ }else{
241
+ if($customerGroupId != $data['customer_group_id']){
242
+ unset($product_rule_data[$key]);
243
+ }else{
244
+
245
+ //check if rule is created by mshop
246
+ $resurce = Mage::getSingleton('core/resource');
247
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
248
+ $mshop_rule_ids = $connection->fetchAll("select rule_id from ".$resurce->getTableName('ecomwise_catalogpromotions_mapping')."");
249
+ $isMshop = false;
250
+ foreach($mshop_rule_ids as $rule){
251
+ if($rule['rule_id']==$data['rule_id']){
252
+ $isMshop = true;
253
+ }
254
+ }
255
+
256
+ if($isMshop){
257
+ //rule price is calculated for later filtering, and if highes, rule_id is stored in $hihgest.
258
+ $rule_price = Mage::helper('catalogrule')->calcPriceRule(
259
+ $data['action_operator'],
260
+ $data['action_amount'],
261
+ $productPrice);
262
+ if($rule_price < $price_start){
263
+ $price_start = $rule_price;
264
+ $highest = $key;
265
+ }
266
+ //used for later filtering of highest discount rule
267
+ $individual[] = $key;
268
+ }
269
+ }
270
+
271
+ }
272
+ }
273
+ //filter highest discount rule if configuration is on only for individual rules
274
+ if(Mage::getStoreConfig("mshopb2b/parameters/applyhighestrule", 0)){
275
+ $diffrence = array_diff ($individual, array($highest));
276
+ foreach($diffrence as $array_key){
277
+ unset($product_rule_data[$array_key]);
278
+ }
279
+
280
+ }
281
+ return $product_rule_data;
282
+ }
283
+
284
+ }
app/code/community/Ecomwise/MshopB2B/Model/Sales/Tax/Subtotal.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_Sales_Tax_Subtotal extends Mage_Tax_Model_Sales_Total_Quote_Subtotal{
3
+
4
+ public function collect(Mage_Sales_Model_Quote_Address $address)
5
+ {
6
+
7
+
8
+ $items = $this->_getAddressItems($address);
9
+ foreach ($items as $item) {
10
+ if($item->getApiCreated()){
11
+ return $this;
12
+ }
13
+ }
14
+
15
+ $this->_store = $address->getQuote()->getStore();
16
+ $this->_address = $address;
17
+
18
+ $this->_subtotalInclTax = 0;
19
+ $this->_baseSubtotalInclTax = 0;
20
+ $this->_subtotal = 0;
21
+ $this->_baseSubtotal = 0;
22
+ $this->_roundingDeltas = array();
23
+
24
+ $address->setSubtotalInclTax(0);
25
+ $address->setBaseSubtotalInclTax(0);
26
+ $address->setTotalAmount('subtotal', 0);
27
+ $address->setBaseTotalAmount('subtotal', 0);
28
+
29
+
30
+ if (!$items) {
31
+ return $this;
32
+ }
33
+
34
+ $addressRequest = $this->_getAddressTaxRequest($address);
35
+ $storeRequest = $this->_getStoreTaxRequest($address);
36
+ $this->_calculator->setCustomer($address->getQuote()->getCustomer());
37
+ if ($this->_config->priceIncludesTax($this->_store)) {
38
+ $classIds = array();
39
+ foreach ($items as $item) {
40
+ $classIds[] = $item->getProduct()->getTaxClassId();
41
+ if ($item->getHasChildren()) {
42
+ foreach ($item->getChildren() as $child) {
43
+ $classIds[] = $child->getProduct()->getTaxClassId();
44
+ }
45
+ }
46
+ }
47
+ $classIds = array_unique($classIds);
48
+ $storeRequest->setProductClassId($classIds);
49
+ $addressRequest->setProductClassId($classIds);
50
+ $this->_areTaxRequestsSimilar = $this->_calculator->compareRequests($storeRequest, $addressRequest);
51
+ }
52
+
53
+ foreach ($items as $item) {
54
+ if ($item->getParentItem()) {
55
+ continue;
56
+ }
57
+ //if($item->getApiCreated()== true){
58
+ //return $this;
59
+ //}
60
+ if ($item->getHasChildren() && $item->isChildrenCalculated()) {
61
+ foreach ($item->getChildren() as $child) {
62
+ $this->_processItem($child, $addressRequest);
63
+ }
64
+ $this->_recalculateParent($item);
65
+ } else {
66
+ $this->_processItem($item, $addressRequest);
67
+ }
68
+ $this->_addSubtotalAmount($address, $item);
69
+ }
70
+ $address->setRoundingDeltas($this->_roundingDeltas);
71
+ return $this;
72
+ }
73
+
74
+
75
+ }
app/code/community/Ecomwise/MshopB2B/Model/SalesRule/Validator.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ecomwise_MshopB2B_Model_SalesRule_Validator extends Mage_SalesRule_Model_Validator{
3
+ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
4
+ {
5
+ $item->setDiscountAmount(0);
6
+ $item->setBaseDiscountAmount(0);
7
+ $item->setDiscountPercent(0);
8
+
9
+ //$api_order_create = Mage::registry('api_order_create_run');
10
+
11
+ //if($item->getApiCreated()){
12
+ // return $this;
13
+ //}
14
+ $quote = $item->getQuote();
15
+ $address = $this->_getAddress($item);
16
+
17
+ $itemPrice = $this->_getItemPrice($item);
18
+ $baseItemPrice = $this->_getItemBasePrice($item);
19
+
20
+ if ($itemPrice <= 0) {
21
+ return $this;
22
+ }
23
+
24
+ $appliedRuleIds = array();
25
+ foreach ($this->_getRules() as $rule) {
26
+
27
+
28
+
29
+ if($rule->getName() == "API-created-rule-for-order-upload"){
30
+ if(!$item->getApiCreated()){
31
+ continue;
32
+ }
33
+ }else{
34
+ if($item->getApiCreated()){
35
+ continue;
36
+ }
37
+ }
38
+
39
+
40
+
41
+ /* @var $rule Mage_SalesRule_Model_Rule */
42
+ if (!$this->_canProcessRule($rule, $address)) {
43
+ continue;
44
+ }
45
+
46
+ if (!$rule->getActions()->validate($item)) {
47
+ continue;
48
+ }
49
+
50
+ $qty = $this->_getItemQty($item, $rule);
51
+ $rulePercent = min(100, $rule->getDiscountAmount());
52
+
53
+ $discountAmount = 0;
54
+ $baseDiscountAmount = 0;
55
+ switch ($rule->getSimpleAction()) {
56
+ case Mage_SalesRule_Model_Rule::TO_PERCENT_ACTION:
57
+ $rulePercent = max(0, 100-$rule->getDiscountAmount());
58
+ //no break;
59
+ case Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION:
60
+ $step = $rule->getDiscountStep();
61
+ if ($step) {
62
+ $qty = floor($qty/$step)*$step;
63
+ }
64
+ $discountAmount = ($qty*$itemPrice - $item->getDiscountAmount()) * $rulePercent/100;
65
+ $baseDiscountAmount= ($qty*$baseItemPrice - $item->getBaseDiscountAmount()) * $rulePercent/100;
66
+
67
+ if (!$rule->getDiscountQty() || $rule->getDiscountQty()>$qty) {
68
+ $discountPercent = min(100, $item->getDiscountPercent()+$rulePercent);
69
+ $item->setDiscountPercent($discountPercent);
70
+ }
71
+ break;
72
+ case Mage_SalesRule_Model_Rule::TO_FIXED_ACTION:
73
+ $quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
74
+ $discountAmount = $qty*($itemPrice-$quoteAmount);
75
+ $baseDiscountAmount= $qty*($baseItemPrice-$rule->getDiscountAmount());
76
+ break;
77
+
78
+ case Mage_SalesRule_Model_Rule::BY_FIXED_ACTION:
79
+ $step = $rule->getDiscountStep();
80
+ if ($step) {
81
+ $qty = floor($qty/$step)*$step;
82
+ }
83
+ $quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
84
+ $discountAmount = $qty*$quoteAmount;
85
+ $baseDiscountAmount = $qty*$rule->getDiscountAmount();
86
+ break;
87
+
88
+ case Mage_SalesRule_Model_Rule::CART_FIXED_ACTION:
89
+ if (empty($this->_rulesItemTotals[$rule->getId()])) {
90
+ Mage::throwException(Mage::helper('salesrule')->__('Item totals are not set for rule.'));
91
+ }
92
+
93
+ /**
94
+ * prevent applying whole cart discount for every shipping order, but only for first order
95
+ */
96
+ if ($quote->getIsMultiShipping()) {
97
+ $usedForAddressId = $this->getCartFixedRuleUsedForAddress($rule->getId());
98
+ if ($usedForAddressId && $usedForAddressId != $address->getId()) {
99
+ break;
100
+ } else {
101
+ $this->setCartFixedRuleUsedForAddress($rule->getId(), $address->getId());
102
+ }
103
+ }
104
+ $cartRules = $address->getCartFixedRules();
105
+ if (!isset($cartRules[$rule->getId()])) {
106
+ $cartRules[$rule->getId()] = $rule->getDiscountAmount();
107
+ }
108
+
109
+ if ($cartRules[$rule->getId()] > 0) {
110
+ if ($this->_rulesItemTotals[$rule->getId()]['items_count'] <= 1) {
111
+ $quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
112
+ $baseDiscountAmount = min($baseItemPrice * $qty, $cartRules[$rule->getId()]);
113
+ } else {
114
+ $discountRate = $baseItemPrice * $qty / $this->_rulesItemTotals[$rule->getId()]['base_items_price'];
115
+ $maximumItemDiscount = $rule->getDiscountAmount() * $discountRate;
116
+ $quoteAmount = $quote->getStore()->convertPrice($maximumItemDiscount);
117
+
118
+ $baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount);
119
+ $this->_rulesItemTotals[$rule->getId()]['items_count']--;
120
+ }
121
+
122
+ $discountAmount = min($itemPrice * $qty, $quoteAmount);
123
+ $discountAmount = $quote->getStore()->roundPrice($discountAmount);
124
+ $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
125
+ $cartRules[$rule->getId()] -= $baseDiscountAmount;
126
+ }
127
+ $address->setCartFixedRules($cartRules);
128
+
129
+ break;
130
+
131
+ case Mage_SalesRule_Model_Rule::BUY_X_GET_Y_ACTION:
132
+ $x = $rule->getDiscountStep();
133
+ $y = $rule->getDiscountAmount();
134
+ if (!$x || $y>=$x) {
135
+ break;
136
+ }
137
+ $buyAndDiscountQty = $x + $y;
138
+
139
+ $fullRuleQtyPeriod = floor($qty / $buyAndDiscountQty);
140
+ $freeQty = $qty - $fullRuleQtyPeriod * $buyAndDiscountQty;
141
+
142
+ $discountQty = $fullRuleQtyPeriod * $y;
143
+ if ($freeQty > $x) {
144
+ $discountQty += $freeQty - $x;
145
+ }
146
+
147
+ $discountAmount = $discountQty * $itemPrice;
148
+ $baseDiscountAmount= $discountQty * $baseItemPrice;
149
+ break;
150
+ }
151
+
152
+ $result = new Varien_Object(array(
153
+ 'discount_amount' => $discountAmount,
154
+ 'base_discount_amount' => $baseDiscountAmount,
155
+ ));
156
+ Mage::dispatchEvent('salesrule_validator_process', array(
157
+ 'rule' => $rule,
158
+ 'item' => $item,
159
+ 'address' => $address,
160
+ 'quote' => $quote,
161
+ 'qty' => $qty,
162
+ 'result' => $result,
163
+ ));
164
+
165
+ $discountAmount = $result->getDiscountAmount();
166
+ $baseDiscountAmount = $result->getBaseDiscountAmount();
167
+
168
+ $percentKey = $item->getDiscountPercent();
169
+ /**
170
+ * Process "delta" rounding
171
+ */
172
+ if ($percentKey) {
173
+ $delta = isset($this->_roundingDeltas[$percentKey]) ? $this->_roundingDeltas[$percentKey] : 0;
174
+ $baseDelta = isset($this->_baseRoundingDeltas[$percentKey]) ? $this->_baseRoundingDeltas[$percentKey] : 0;
175
+ $discountAmount+= $delta;
176
+ $baseDiscountAmount+=$baseDelta;
177
+
178
+ $this->_roundingDeltas[$percentKey] = $discountAmount - $quote->getStore()->roundPrice($discountAmount);
179
+ $this->_baseRoundingDeltas[$percentKey] = $baseDiscountAmount - $quote->getStore()->roundPrice($baseDiscountAmount);
180
+ $discountAmount = $quote->getStore()->roundPrice($discountAmount);
181
+ $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
182
+ } else {
183
+ $discountAmount = $quote->getStore()->roundPrice($discountAmount);
184
+ $baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
185
+ }
186
+
187
+ /**
188
+ * We can't use row total here because row total not include tax
189
+ * Discount can be applied on price included tax
190
+ */
191
+ $discountAmount = min($item->getDiscountAmount()+$discountAmount, $itemPrice*$qty);
192
+ $baseDiscountAmount = min($item->getBaseDiscountAmount()+$baseDiscountAmount, $baseItemPrice*$qty);
193
+
194
+ $item->setDiscountAmount($discountAmount);
195
+ $item->setBaseDiscountAmount($baseDiscountAmount);
196
+
197
+ $appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
198
+
199
+ $this->_maintainAddressCouponCode($address, $rule);
200
+ $this->_addDiscountDescription($address, $rule);
201
+
202
+ if ($rule->getStopRulesProcessing()) {
203
+ break;
204
+ }
205
+ }
206
+
207
+ $item->setAppliedRuleIds(join(',',$appliedRuleIds));
208
+ $address->setAppliedRuleIds($this->mergeIds($address->getAppliedRuleIds(), $appliedRuleIds));
209
+ $quote->setAppliedRuleIds($this->mergeIds($quote->getAppliedRuleIds(), $appliedRuleIds));
210
+
211
+ return $this;
212
+ }
213
+
214
+
215
+ }
app/code/community/Ecomwise/MshopB2B/controllers/CartController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once('Mage/Checkout/controllers/CartController.php');
3
+
4
+ class Ecomwise_MshopB2B_CartController extends Mage_Checkout_CartController{
5
+
6
+
7
+ public function addAction(){
8
+
9
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
10
+ if($customer){
11
+ $is_blocked = $customer->getMshopBloked();
12
+ if($customer->getMshopBloked() == 1){
13
+ $this->_getSession()->addError($this->__("Your account is blocked from shopping in the webshop! Contact store owners for unblocking your account!"));
14
+ $this->_goBack();
15
+ return;
16
+ }
17
+ }
18
+
19
+ parent::addAction();
20
+
21
+ }
22
+
23
+ public function addgroupAction(){
24
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
25
+ if($customer){
26
+ $is_blocked = $customer->getMshopBloked();
27
+ if($customer->getMshopBloked() == 1){
28
+ $this->_getSession()->addError($this->__("Your account is blocked from shopping in the webshop! Contact store owners for unblocking your account!"));
29
+ $this->_goBack();
30
+ return;
31
+ }
32
+ }
33
+
34
+ parent::addgroupAction();
35
+
36
+ }
37
+
38
+ }
app/code/community/Ecomwise/MshopB2B/controllers/OrderController.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once('Mage/Sales/controllers/OrderController.php');
4
+
5
+ class Ecomwise_MshopB2B_OrderController extends Mage_Sales_OrderController{
6
+
7
+ protected function _goBack()
8
+ {
9
+ $returnUrl = $this->getRequest()->getParam('return_url');
10
+ if ($returnUrl) {
11
+ // clear layout messages in case of external url redirect
12
+ if ($this->_isUrlInternal($returnUrl)) {
13
+ $this->_getSession()->getMessages(true);
14
+ }
15
+ $this->getResponse()->setRedirect($returnUrl);
16
+ } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
17
+ && !$this->getRequest()->getParam('in_cart')
18
+ && $backUrl = $this->_getRefererUrl()
19
+ ) {
20
+ $this->getResponse()->setRedirect($backUrl);
21
+ } else {
22
+ if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
23
+ $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
24
+ }
25
+ $this->_redirect('checkout/cart');
26
+ }
27
+ return $this;
28
+ }
29
+
30
+ public function reorderAction(){
31
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
32
+ if($customer){
33
+
34
+ $is_blocked = $customer->getMshopBloked();
35
+ if($customer->getMshopBloked() == 1){
36
+ Mage::getSingleton('checkout/session')->addError($this->__("Your account is blocked from shopping in the webshop! Contact store owners for unblocking your account!"));
37
+ $this->_goBack();
38
+ return;
39
+ }
40
+ }
41
+
42
+ parent::reorderAction();
43
+ }
44
+ }
45
+
app/code/community/Ecomwise/MshopB2B/etc/api.xml ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <api>
4
+ <resources>
5
+ <!-- mamut methods -->
6
+ <mshop_mamut translate="title" module="mshopb2b">
7
+ <model>mshopb2b/api_mamut_api</model>
8
+ <title>Mamut Methods Api</title>
9
+ <acl>mshopb2b/mamut</acl>
10
+ <methods>
11
+ <setMamutId translate="title" module="mshopb2b">
12
+ <title>Set the mamut ID for multiple customers</title>
13
+ <method>setMamutId</method>
14
+ </setMamutId>
15
+
16
+ <removeMamutMapping translate="title" module="mshopb2b">
17
+ <title>Remove mamut to customer mapping</title>
18
+ <method>removeMamutMapping</method>
19
+ </removeMamutMapping>
20
+
21
+ </methods>
22
+ <faults>
23
+ <mapping_allready_exists>
24
+ <code>100</code>
25
+ <message>There is allreday mapping with this customer id and mamut id</message>
26
+ </mapping_allready_exists>
27
+ <customer_id_allready_exists>
28
+ <code>101</code>
29
+ <message>Customer id is allready mapped to mamut id</message>
30
+ </customer_id_allready_exists>
31
+ <mapping_not_found>
32
+ <code>102</code>
33
+ <message>Mapping for provided id's was not found</message>
34
+ </mapping_not_found>
35
+ <customer_id_not_exists>
36
+ <code>103</code>
37
+ <message>There is no mamut id mapped to this customer id</message>
38
+ </customer_id_not_exists>
39
+
40
+
41
+ <invalid_data_provided>
42
+ <code>104</code>
43
+ <message>Invalid data provided</message>
44
+ </invalid_data_provided>
45
+
46
+ <customer_not_exists_for_mamut_id>
47
+ <code>105</code>
48
+ <message>There is no magento customer mapped to this mamut id</message>
49
+ </customer_not_exists_for_mamut_id>
50
+
51
+ <mamut_product_not_exists>
52
+ <code>106</code>
53
+ <message>Product does not exists in magento</message>
54
+ </mamut_product_not_exists>
55
+
56
+ <problems_creating_order>
57
+ <code>107</code>
58
+ <message>Problems occured during creation of the order</message>
59
+ </problems_creating_order>
60
+
61
+ <problems_generating_invoice_for_order>
62
+ <code>108</code>
63
+ <message>Problem genearting invoice for this order</message>
64
+ </problems_generating_invoice_for_order>
65
+
66
+ <can_not_create_product>
67
+ <code>110</code>
68
+ <message>Problem creating simple product for order</message>
69
+ </can_not_create_product>
70
+
71
+ <magento_customer_not_exists>
72
+ <code>111</code>
73
+ <message>There is no magento customer with this ID</message>
74
+ </magento_customer_not_exists>
75
+
76
+ </faults>
77
+ </mshop_mamut>
78
+ <!-- end of mamut methods -->
79
+
80
+ <!-- mshop credit methods -->
81
+ <mshop_credit translate="title" module="mshopb2b">
82
+ <model>mshopb2b/api_credit_api</model>
83
+ <title>Credit Methods Api</title>
84
+ <acl>mshopb2b/credit</acl>
85
+ <methods>
86
+ <stop translate="title" module="mshopb2b">
87
+ <title>Stop Customer from shopping in magento</title>
88
+ <method>block</method>
89
+ </stop>
90
+
91
+ <unblock translate="title" module="mshopb2b">
92
+ <title>Remove customer shopping ban in magento</title>
93
+ <method>unblock</method>
94
+ </unblock>
95
+
96
+ </methods>
97
+ <faults>
98
+ <email_not_sent>
99
+ <code>100</code>
100
+ <message>Email not sent</message>
101
+ </email_not_sent>
102
+ <customer_not_exists>
103
+ <code>100</code>
104
+ <message>Customer with provided email not exists</message>
105
+ </customer_not_exists>
106
+ <customer_allready_blocked>
107
+ <code>101</code>
108
+ <message>Customer with this email is allready blocked</message>
109
+ </customer_allready_blocked>
110
+
111
+ <customer_allready_unblocked>
112
+ <code>102</code>
113
+ <message>Customer with this email is allready unblocked</message>
114
+ </customer_allready_unblocked>
115
+ </faults>
116
+ </mshop_credit>
117
+ <!-- end mshop credit methods -->
118
+
119
+ <!-- customer methods -->
120
+ <mshop_m_customer translate="title" module="mshopb2b">
121
+ <model>mshopb2b/api_customer_api</model>
122
+ <title>Customer Methods Api</title>
123
+ <acl>mshopb2b/customer</acl>
124
+ <methods>
125
+ <updatePreferedLocale translate="title" module="mshopb2b">
126
+ <title>Update Customer prefered locale</title>
127
+ <method>updatePreferedLocale</method>
128
+ </updatePreferedLocale>
129
+
130
+ <createCustomerGroup translate="title" module="mshopb2b">
131
+ <title>Create Customer Group by Name for given Tax Class Id</title>
132
+ <method>createCustomerGroup</method>
133
+ </createCustomerGroup>
134
+
135
+ <assignCustomerToGroup translate="title" module="mshopb2b">
136
+ <title>Assigns a customer to a given customer group</title>
137
+ <method>assignCustomerToGroup</method>
138
+ </assignCustomerToGroup>
139
+
140
+ <update translate="title" module="mshopb2b">
141
+ <title>Update customer information and invoice and billing adress</title>
142
+ <method>update</method>
143
+ </update>
144
+
145
+ <create translate="title" module="mshopb2b">
146
+ <title>Create customer with invoice and billing adress</title>
147
+ <method>create</method>
148
+ </create>
149
+
150
+ <getCustomersChangedSince>
151
+ <title>Get list of customers updated since date</title>
152
+ <method>updatedSince</method>
153
+ </getCustomersChangedSince>
154
+
155
+
156
+ </methods>
157
+ <faults module="mshopb2b">
158
+ <unknown_mcustomer>
159
+ <code>101</code>
160
+ <message>Non existing Magento customer, invalid customer ID provided</message>
161
+ </unknown_mcustomer>
162
+ <unknown_mgroup>
163
+ <code>102</code>
164
+ <message>Non existing customer group, invalid ID provided</message>
165
+ </unknown_mgroup>
166
+ <unknown_mtaxclass>
167
+ <code>103</code>
168
+ <message>Non existing tax class, invalid ID provided</message>
169
+ </unknown_mtaxclass>
170
+ <customer_not_exists_for_mamut_id>
171
+ <code>104</code>
172
+ <message>There is no magento customer mapped to this mamut id</message>
173
+ </customer_not_exists_for_mamut_id>
174
+ <customer_information_update_failed>
175
+ <code>105</code>
176
+ <message>Cutsomer data update was not successful</message>
177
+ </customer_information_update_failed>
178
+ <address_information_update_failed>
179
+ <code>106</code>
180
+ <message>Address data update was not successful</message>
181
+ </address_information_update_failed>
182
+
183
+ <customer_creation_failed>
184
+ <code>107</code>
185
+ <message>Customer creation failed</message>
186
+ </customer_creation_failed>
187
+ <mamut_id_not_set_for_customer>
188
+ <code>108</code>
189
+ <message>Mamut id was not set for customer</message>
190
+ </mamut_id_not_set_for_customer>
191
+
192
+ <address_creation_failed>
193
+ <code>109</code>
194
+ <message>Address creation for customer failed</message>
195
+ </address_creation_failed>
196
+ <mapped_customer_not_exists_for_mamut_id>
197
+ <code>110</code>
198
+ <message>There is customer mapped to this mamut id, but customer not exists in magneto</message>
199
+ </mapped_customer_not_exists_for_mamut_id>
200
+ <customer_create_incomplete_data>
201
+ <code>111</code>
202
+ <message>Incomplete customer creation data. Missing parts: </message>
203
+ </customer_create_incomplete_data>
204
+ <customer_create_customer_allready_exists>
205
+ <code>112</code>
206
+ <message>Customer with this email for this website already exists</message>
207
+ </customer_create_customer_allready_exists>
208
+
209
+ </faults>
210
+ </mshop_m_customer>
211
+ <!-- end of customer methods -->
212
+
213
+ <!-- promotions methods -->
214
+ <mshop_promotions translate="title" module="mshopb2b">
215
+ <model>mshopb2b/api_promotions_api</model>
216
+ <title>Promotions Methods Api</title>
217
+ <acl>mshopb2b/promotions</acl>
218
+ <methods>
219
+ <checkCreateFixedPriceForCustomer translate="title" module="mshopb2b">
220
+ <title>Create Fixed Price For Customer</title>
221
+ <method>checkCreateFixedPriceForCustomer</method>
222
+ <acl>promotions/createfixedpriceforcustomer</acl>
223
+ </checkCreateFixedPriceForCustomer>
224
+
225
+ <checkCreateDiscountForCustomer translate="title" module="mshopb2b">
226
+ <title>Create Discount For Customer</title>
227
+ <method>checkCreateDiscountForCustomer</method>
228
+ <acl>promotions/creatediscountforcustomer</acl>
229
+ </checkCreateDiscountForCustomer>
230
+
231
+ <checkCreateDiscountCategoryForCustomer translate="title" module="mshopb2b">
232
+ <title>Create Discount For Customer For Given Category</title>
233
+ <method>checkCreateDiscountCategoryForCustomer</method>
234
+ <acl>promotions/creatediscountforcustomercategory</acl>
235
+ </checkCreateDiscountCategoryForCustomer>
236
+
237
+ <checkCreateFixedPriceForCustomerGroup translate="title" module="mshopb2b">
238
+ <title>Create Fixed Price for Customer Group</title>
239
+ <method>checkCreateFixedPriceForCustomerGroup</method>
240
+ <acl>promotions/createfixedpriceforcustomergroup</acl>
241
+ </checkCreateFixedPriceForCustomerGroup>
242
+
243
+ <checkCreateDiscountForCustomerGroup translate="title" module="mshopb2b">
244
+ <title>Create Discount for Customer Group</title>
245
+ <method>checkCreateDiscountForCustomerGroup</method>
246
+ <acl>promotions/creatediscountforcustomergroup</acl>
247
+ </checkCreateDiscountForCustomerGroup>
248
+
249
+ <checkCreateDiscountCategoryForCustomerGroup translate="title" module="mshopb2b">
250
+ <title>Create Discount on Category for Customer Group</title>
251
+ <method>checkCreateDiscountCategoryForCustomerGroup</method>
252
+ <acl>promotions/creatediscountcategoryforcustomergroup</acl>
253
+ </checkCreateDiscountCategoryForCustomerGroup>
254
+
255
+ <deleteDiscountRulesExcept translate="title" module="mshopb2b">
256
+ <title>Delete Discount Rules Except Passed</title>
257
+ <method>deleteDiscountRule</method>
258
+ <acl>promotions/deletediscountrule</acl>
259
+ </deleteDiscountRulesExcept>
260
+
261
+ <checkCreateDefaultDiscountForCustomer>
262
+ <title>Create rule for default discount on all prdoucts for customer</title>
263
+ <method>checkCreateDefaultDiscountForCustomer</method>
264
+ <acl>promotions/creatediscountforcustomer</acl>
265
+ </checkCreateDefaultDiscountForCustomer>
266
+
267
+ <applyDiscountRules>
268
+ <title>Apply Rules</title>
269
+ <method>applyRules</method>
270
+ <acl>promotions/applyRules</acl>
271
+ </applyDiscountRules>
272
+
273
+ </methods>
274
+ <faults>
275
+ <no_rules_found>
276
+ <code>100</code>
277
+ <message>No catalog promotions where found.</message>
278
+ </no_rules_found>
279
+
280
+ <code_not_valid>
281
+ <code>101</code>
282
+ <message>Rule setting is not valid.</message>
283
+ </code_not_valid>
284
+
285
+ <customer_group_not_exists>
286
+ <code>102</code>
287
+ <message>Customer group is not valid.</message>
288
+ </customer_group_not_exists>
289
+
290
+ <customerids_array_not_passed>
291
+ <code>103</code>
292
+ <message>Customer ids should be passed as array.</message>
293
+ </customerids_array_not_passed>
294
+
295
+ <website_not_exists>
296
+ <code>104</code>
297
+ <message>Website not exists.</message>
298
+ </website_not_exists>
299
+
300
+ <websiteids_array_not_passed>
301
+ <code>105</code>
302
+ <message>Website ids should be passed as array.</message>
303
+ </websiteids_array_not_passed>
304
+
305
+ <not_created>
306
+ <code>106</code>
307
+ <message>Rule is not created.</message>
308
+ </not_created>
309
+
310
+ <rule_not_exists>
311
+ <code>107</code>
312
+ <message>Rule not exists.</message>
313
+ </rule_not_exists>
314
+
315
+ <customerids_array_not_passed>
316
+ <code>108</code>
317
+ <message>Customer ids should be passed as array.</message>
318
+ </customerids_array_not_passed>
319
+
320
+ <module_not_installed>
321
+ <code>109</code>
322
+ <message>Ecomwise_Customerpromotions module not installed.</message>
323
+ </module_not_installed>
324
+
325
+ <mapping_table_not_present>
326
+ <code>110</code>
327
+ <message>Mapping table not present.</message>
328
+ </mapping_table_not_present>
329
+
330
+ <no_customers>
331
+ <code>111</code>
332
+ <message>There are no individual customers for this rule.</message>
333
+ </no_customers>
334
+
335
+ <array_not_pased>
336
+ <code>112</code>
337
+ <message>Rule ids should be passed as array </message>
338
+ </array_not_pased>
339
+
340
+ <array_not_allowed>
341
+ <code>113</code>
342
+ <message>A single string representing product SKU should be passed</message>
343
+ </array_not_allowed>
344
+
345
+ <no_products_assigned_to_category>
346
+ <code>114</code>
347
+ <message>There are no products assigned to this category</message>
348
+ </no_products_assigned_to_category>
349
+ </faults>
350
+ </mshop_promotions>
351
+ <!-- end promotions methods -->
352
+ </resources>
353
+ <resources_alias>
354
+ <m_customer>mshop_m_customer</m_customer>
355
+ <mamut>mshop_mamut</mamut>
356
+ <credit>mshop_credit</credit>
357
+ <promotions>mshop_promotions</promotions>
358
+ </resources_alias>
359
+ <v2>
360
+ <resources_function_prefix>
361
+ <credit>mshopCredit</credit>
362
+ <mamut>mshopMamut</mamut>
363
+ <m_customer>mshopMCustomer</m_customer>
364
+ <promotions>mshopPromotions</promotions>
365
+ </resources_function_prefix>
366
+ </v2>
367
+ <acl>
368
+ <resources>
369
+ <ecomwise translate="title" module="mshopb2b">
370
+ <title>Ecomwise</title>
371
+ <sort_order>100</sort_order>
372
+ <mshopb2b translate="title" module="mshopb2b">
373
+ <title>MshopB2B Api</title>
374
+ <sort_order>100</sort_order>
375
+ <mamut translate="title" module="mshopb2b">
376
+ <title>Api Mamut Methods</title>
377
+ <sort_order>101</sort_order>
378
+ </mamut>
379
+ <credit translate="title" module="mshopb2b">
380
+ <title>Api Customer Credit Methods</title>
381
+ <sort_order>102</sort_order>
382
+ </credit>
383
+ <promotions translate="title" module="mshopb2b">
384
+ <title>Api Promotions Methods</title>
385
+ <sort_order>103</sort_order>
386
+ <createfixedpriceforcustomer translate="title" module="mshopb2b">
387
+ <title>Create Fixed Price For Customer</title>
388
+ </createfixedpriceforcustomer>
389
+
390
+ <creatediscountforcustomer translate="title" module="mshopb2b">
391
+ <title>Create Discount For Customer</title>
392
+ </creatediscountforcustomer>
393
+
394
+ <creatediscountforcustomercategory translate="title" module="mshopb2b">
395
+ <title>Create Discount For Customer For Given Category</title>
396
+ </creatediscountforcustomercategory>
397
+
398
+ <createfixedpriceforcustomergroup translate="title" module="mshopb2b">
399
+ <title>Create Fixed Price For Customer Group</title>
400
+ </createfixedpriceforcustomergroup>
401
+
402
+ <creatediscountforcustomergroup translate="title" module="mshopb2b">
403
+ <title>Create Discount for Customer Group</title>
404
+ </creatediscountforcustomergroup>
405
+
406
+ <creatediscountcategoryforcustomergroup translate="title" module="mshopb2b">
407
+ <title>Create Discount on Category For Customer Group</title>
408
+ </creatediscountcategoryforcustomergroup>
409
+
410
+ <deletediscountrule translate="title" module="mshopb2b">
411
+ <title>Delete Discount Rule</title>
412
+ </deletediscountrule>
413
+
414
+ <applyRules translate="title" module="mshopb2b">
415
+ <title>Apply Discount Rules</title>
416
+ </applyRules>
417
+
418
+ </promotions>
419
+ <customer>
420
+
421
+ </customer>
422
+ </mshopb2b>
423
+ </ecomwise>
424
+ </resources>
425
+ </acl>
426
+ </api>
427
+ </config>
app/code/community/Ecomwise/MshopB2B/etc/config.xml ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ecomwise_MshopB2B>
5
+ <version>1.2.7</version>
6
+ </Ecomwise_MshopB2B>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <checkout>
11
+ <args>
12
+ <modules>
13
+ <ecomwise_mshopb2b before="Mage_Checkout">Ecomwise_MshopB2B</ecomwise_mshopb2b>
14
+ </modules>
15
+ </args>
16
+ </checkout>
17
+ <sales>
18
+ <args>
19
+ <modules>
20
+ <ecomwise_mshopb2b before="Mage_Sales">Ecomwise_MshopB2B</ecomwise_mshopb2b>
21
+ </modules>
22
+ </args>
23
+ </sales>
24
+ </routers>
25
+ <events>
26
+ <catalog_product_collection_load_after>
27
+ <observers>
28
+ <mshopb2b>
29
+ <class>mshopb2b/observer</class>
30
+ <method>prepareCollection</method>
31
+ </mshopb2b>
32
+ </observers>
33
+ </catalog_product_collection_load_after>
34
+ </events>
35
+ </frontend>
36
+ <global>
37
+ <models>
38
+ <mshopb2b>
39
+ <class>Ecomwise_MshopB2B_Model</class>
40
+ <resourceModel>mshopb2b_mysql4</resourceModel>
41
+ </mshopb2b>
42
+
43
+ <mshopb2b_mysql4>
44
+ <class>Ecomwise_MshopB2B_Model_Mysql4</class>
45
+ <entities>
46
+ <mshopb2b_customer>
47
+ <table>ecomwise_customerpromotions_mapping</table>
48
+ </mshopb2b_customer>
49
+ <mshopb2b_catalog>
50
+ <table>ecomwise_catalogpromotions_mapping</table>
51
+ </mshopb2b_catalog>
52
+ <mshopb2b>
53
+ <table>ecomwise_customermamut_mapping</table>
54
+ </mshopb2b>
55
+ <mshopb2b_contact>
56
+ <table>ecomwise_mamut_contact_groups</table>
57
+ </mshopb2b_contact>
58
+ </entities>
59
+ </mshopb2b_mysql4>
60
+ <catalogrule>
61
+ <!-- <rewrite>
62
+ <rule>Ecomwise_MshopB2B_Model_Rules_CatalogRule</rule>
63
+ </rewrite> -->
64
+ <rewrite>
65
+ <rule_condition_combine>Ecomwise_MshopB2B_Model_Rules_Combine</rule_condition_combine>
66
+ </rewrite>
67
+ </catalogrule>
68
+ <catalogrule_mysql4>
69
+ <rewrite>
70
+ <rule>Ecomwise_MshopB2B_Model_Rules_MySQL4Rule</rule>
71
+ </rewrite>
72
+ </catalogrule_mysql4>
73
+ <catalogrule_resource>
74
+ <rewrite>
75
+ <rule_collection>Ecomwise_MshopB2B_Model_Collections_RuleCollection</rule_collection>
76
+ </rewrite>
77
+ </catalogrule_resource>
78
+ <salesrule>
79
+ <rewrite>
80
+ <validator>Ecomwise_MshopB2B_Model_SalesRule_Validator</validator>
81
+ </rewrite>
82
+ </salesrule>
83
+ <tax>
84
+ <rewrite>
85
+ <sales_total_quote_subtotal>Ecomwise_MshopB2B_Model_Sales_Tax_Subtotal</sales_total_quote_subtotal>
86
+ </rewrite>
87
+ </tax>
88
+ <customer>
89
+ <rewrite>
90
+ <group>Ecomwise_MshopB2B_Model_Customer_Group</group>
91
+ </rewrite>
92
+ </customer>
93
+ </models>
94
+ <resources>
95
+ <mshopb2b_setup>
96
+ <setup>
97
+ <module>Ecomwise_MshopB2B</module>
98
+ </setup>
99
+ <connection>
100
+ <use>core_setup</use>
101
+ </connection>
102
+ </mshopb2b_setup>
103
+ <mshopb2b_write>
104
+ <connection>
105
+ <use>core_write</use>
106
+ </connection>
107
+ </mshopb2b_write>
108
+ <mshopb2b_read>
109
+ <connection>
110
+ <use>core_read</use>
111
+ </connection>
112
+ </mshopb2b_read>
113
+ </resources>
114
+ <blocks>
115
+ <mshopb2b>
116
+ <class>Ecomwise_MshopB2B_Block</class>
117
+ </mshopb2b>
118
+ <adminhtml>
119
+ <rewrite>
120
+ <promo_catalog_grid>Ecomwise_MshopB2B_Block_Adminhtml_EcomwisePromoCatalogGrid</promo_catalog_grid>
121
+ <promo_catalog_edit_tab_main>Ecomwise_MshopB2B_Block_Adminhtml_EcomwisePromoCatalogEditTab</promo_catalog_edit_tab_main>
122
+ <customer_grid>Ecomwise_MshopB2B_Block_Adminhtml_EcomwiseCustomerGrid</customer_grid>
123
+ <sales_order_create_shipping_method_form>Ecomwise_MshopB2B_Block_Adminhtml_Sales_Order_Create_Shipping_Method_Form</sales_order_create_shipping_method_form>
124
+ </rewrite>
125
+ </adminhtml>
126
+ </blocks>
127
+ <helpers>
128
+ <mshopb2b>
129
+ <class>Ecomwise_MshopB2B_Helper</class>
130
+ </mshopb2b>
131
+ </helpers>
132
+ <events>
133
+ <catalogrule_rule_delete_after>
134
+ <observers>
135
+ <mshopb2b>
136
+ <class>mshopb2b/observer</class>
137
+ <method>afterDeleteRule</method>
138
+ </mshopb2b>
139
+ </observers>
140
+ </catalogrule_rule_delete_after>
141
+ </events>
142
+ </global>
143
+
144
+ <adminhtml>
145
+ <acl>
146
+ <resources>
147
+ <all>
148
+ <title>Allow Everything</title>
149
+ </all>
150
+ <admin>
151
+ <children>
152
+ <system>
153
+ <children>
154
+ <config>
155
+ <children>
156
+ <mshopb2b translate="title" module="mshopb2b">
157
+ <title>Ecomwise MshopB2B</title>
158
+ </mshopb2b>
159
+ </children>
160
+ </config>
161
+ </children>
162
+ </system>
163
+ </children>
164
+ </admin>
165
+ </resources>
166
+ </acl>
167
+ </adminhtml>
168
+ <default>
169
+ <carriers>
170
+ <mamut_shipping>
171
+ <active>1</active>
172
+ <sallowspecific>0</sallowspecific>
173
+ <model>mshopb2b/carrier_mamutshipping</model>
174
+ <name>Mamut Rate</name>
175
+ <title>Mamut Shipping</title>
176
+ </mamut_shipping>
177
+ </carriers>
178
+ <payment>
179
+ <mamut_billing>
180
+ <model>mshopb2b/payment_mamutbilling</model>
181
+ <active>1</active>
182
+ <order_status>mshop_mamut</order_status>
183
+ <title>Mamut Billing</title>
184
+ <payment_action>sale</payment_action>
185
+ <allowspecific>0</allowspecific>
186
+ <method_description>Mamut Billing</method_description>
187
+ </mamut_billing>
188
+ </payment>
189
+ <mshopb2b>
190
+ <parameters>
191
+ <applyhighestrule>0</applyhighestrule>
192
+ <setlogging>0</setlogging>
193
+ </parameters>
194
+ </mshopb2b>
195
+ </default>
196
+ </config>
197
+
app/code/community/Ecomwise/MshopB2B/etc/system.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <mshop_tab translate="label" module="mshopb2b">
5
+ <label>M-shop</label>
6
+ <sort_order>210</sort_order>
7
+ </mshop_tab>
8
+ </tabs>
9
+ <sections>
10
+ <mshopb2b translate="label" module="mshopb2b">
11
+ <label>M-shop B2B</label>
12
+ <tab>mshop_tab</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>110</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <about translate="label">
20
+ <label>About M-shop</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <mshop_version translate="label">
28
+ <label>M-shop B2B</label>
29
+ <frontend_type>select</frontend_type>
30
+ <frontend_model>mshopb2b/system_config_version</frontend_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </mshop_version>
36
+ </fields>
37
+ </about>
38
+ <parameters translate="label">
39
+ <label>Settings</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>3</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <fields>
46
+ <applyhighestrule translate="label">
47
+ <label>Apply highest discount</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>10</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </applyhighestrule>
55
+ <setlogging translate="label">
56
+ <label>Enable M-shopB2B api methods logging</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_yesno</source_model>
59
+ <sort_order>15</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </setlogging>
64
+ </fields>
65
+ </parameters>
66
+ </groups>
67
+ </mshopb2b>
68
+ </sections>
69
+ </config>
app/code/community/Ecomwise/MshopB2B/etc/wsdl.xml ADDED
@@ -0,0 +1,886 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
4
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
5
+ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
6
+ <types>
7
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
8
+ targetNamespace="urn:Magento">
9
+ <import namespace="http://schemas.xmlsoap.org/soap/encoding/"
10
+ schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
11
+ <!-- Customer -->
12
+
13
+ <complexType name="customerCustomerCreateEntity">
14
+ <all>
15
+ <element name="mamut_id" type="xsd:int" minOccurs="0" />
16
+ <element name="customerEntity" type="typens:customerCustomerEntityToCreate" minOccurs="0" />
17
+ <element name="mamut_contact_groups" type="typens:ArrayOfString" minOccurs="0" />
18
+ </all>
19
+ </complexType>
20
+
21
+ <complexType name="customerCustomerCreateAddressEntityArray">
22
+ <complexContent>
23
+ <restriction base="soapenc:Array">
24
+ <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:customerAddressEntityCreate[]" />
25
+ </restriction>
26
+ </complexContent>
27
+ </complexType>
28
+
29
+
30
+ <complexType name="customerCustomerEntityToCreate">
31
+ <all>
32
+ <element name="customer_id" type="xsd:int" minOccurs="0" />
33
+ <element name="email" type="xsd:string" minOccurs="0" />
34
+ <element name="firstname" type="xsd:string" minOccurs="0" />
35
+ <element name="lastname" type="xsd:string" minOccurs="0" />
36
+ <element name="password" type="xsd:string" minOccurs="0" />
37
+ <element name="website_id" type="xsd:int" minOccurs="0" />
38
+ <element name="store_id" type="xsd:int" minOccurs="0" />
39
+ <element name="group_id" type="xsd:int" minOccurs="0" />
40
+ <element name="taxvat" type="xsd:string" minOccurs="0" />
41
+ </all>
42
+ </complexType>
43
+ <complexType name="customerCustomerUpdateEntity">
44
+ <all>
45
+ <element name="customer_id" type="xsd:int" minOccurs="0" />
46
+ <element name="mamut_id" type="xsd:int" minOccurs="0" />
47
+ <element name="customerEntity" type="typens:customerCustomerEntityToCreate" minOccurs="0" />
48
+ <element name="mamut_contact_groups" type="typens:ArrayOfString" minOccurs="0" />
49
+ </all>
50
+ </complexType>
51
+ <complexType name="customerCustomerUpdateAddressEntityArray">
52
+ <complexContent>
53
+ <restriction base="soapenc:Array">
54
+ <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:customerCustomerUpdateAddressEntity[]" />
55
+ </restriction>
56
+ </complexContent>
57
+ </complexType>
58
+ <complexType name="customerCustomerUpdateAddressEntity">
59
+ <all>
60
+ <element name="address_id" type="xsd:int" minOccurs="0" />
61
+ <element name="addressEntity" type="typens:customerAddressEntityCreate" minOccurs="0" />
62
+ </all>
63
+ </complexType>
64
+
65
+ <complexType name="mshopCustomerUpdateEntity">
66
+ <all>
67
+ <element name="mamut_id" type="xsd:int" minOccurs="0" />
68
+ <element name="mamut_contact_groups" type="typens:ArrayOfString" minOccurs="0" />
69
+ <element name="email" type="xsd:string" minOccurs="0" />
70
+ <element name="firstname" type="xsd:string" minOccurs="0" />
71
+ <element name="lastname" type="xsd:string" minOccurs="0" />
72
+ <element name="password" type="xsd:string" minOccurs="0" />
73
+ <element name="website_id" type="xsd:int" minOccurs="0" />
74
+ <element name="store_id" type="xsd:int" minOccurs="0" />
75
+ <element name="group_id" type="xsd:int" minOccurs="0" />
76
+ <element name="taxvat" type="xsd:string" minOccurs="0" />
77
+ </all>
78
+ </complexType>
79
+ <complexType name="mshopAddressUpdateEntityForDefaultBillingAddress">
80
+ <all>
81
+ <element name="city" type="xsd:string" minOccurs="0"/>
82
+ <element name="company" type="xsd:string" minOccurs="0"/>
83
+ <element name="country_id" type="xsd:string" minOccurs="0"/>
84
+ <element name="fax" type="xsd:string" minOccurs="0"/>
85
+ <element name="firstname" type="xsd:string" minOccurs="0"/>
86
+ <element name="lastname" type="xsd:string" minOccurs="0"/>
87
+ <element name="middlename" type="xsd:string" minOccurs="0"/>
88
+ <element name="postcode" type="xsd:string" minOccurs="0"/>
89
+ <element name="prefix" type="xsd:string" minOccurs="0"/>
90
+ <element name="region_id" type="xsd:int" minOccurs="0"/>
91
+ <element name="region" type="xsd:string" minOccurs="0"/>
92
+ <element name="street" type="typens:ArrayOfString" minOccurs="0"/>
93
+ <element name="suffix" type="xsd:string" minOccurs="0"/>
94
+ <element name="telephone" type="xsd:string" minOccurs="0"/>
95
+ <element name="is_default_billing" type="xsd:boolean" minOccurs="0"/>
96
+ <element name="is_default_shipping" type="xsd:boolean" minOccurs="0"/>
97
+ </all>>
98
+ </complexType>
99
+ <complexType name="mshopAddressUpdateEntityForDefaultShippingAddress">
100
+ <all>
101
+ <element name="city" type="xsd:string" minOccurs="0"/>
102
+ <element name="company" type="xsd:string" minOccurs="0"/>
103
+ <element name="country_id" type="xsd:string" minOccurs="0"/>
104
+ <element name="fax" type="xsd:string" minOccurs="0"/>
105
+ <element name="firstname" type="xsd:string" minOccurs="0"/>
106
+ <element name="lastname" type="xsd:string" minOccurs="0"/>
107
+ <element name="middlename" type="xsd:string" minOccurs="0"/>
108
+ <element name="postcode" type="xsd:string" minOccurs="0"/>
109
+ <element name="prefix" type="xsd:string" minOccurs="0"/>
110
+ <element name="region_id" type="xsd:int" minOccurs="0"/>
111
+ <element name="region" type="xsd:string" minOccurs="0"/>
112
+ <element name="street" type="typens:ArrayOfString" minOccurs="0"/>
113
+ <element name="suffix" type="xsd:string" minOccurs="0"/>
114
+ <element name="telephone" type="xsd:string" minOccurs="0"/>
115
+ <element name="is_default_billing" type="xsd:boolean" minOccurs="0"/>
116
+ <element name="is_default_shipping" type="xsd:boolean" minOccurs="0"/>
117
+ </all>>
118
+ </complexType>
119
+ <!-- End customer -->
120
+
121
+ <!-- Promotions -->
122
+
123
+ <complexType name="mshopPromotionsListCatalogPromotionsEntity">
124
+ <all>
125
+ <element name="rule_id" type="xsd:int" minOccurs="0" />
126
+ <element name="name" type="xsd:string" minOccurs="0" />
127
+ <element name="description" type="xsd:string" minOccurs="0" />
128
+ <element name="from_date" type="xsd:string" minOccurs="0" />
129
+ <element name="to_date" type="xsd:string" minOccurs="0" />
130
+ <element name="customer_group_ids" type="xsd:string"
131
+ minOccurs="0" />
132
+ <element name="is_active" type="xsd:int" minOccurs="0" />
133
+ <element name="stop_rules_processing" type="xsd:int"
134
+ minOccurs="0" />
135
+ <element name="sort_order" type="xsd:int" minOccurs="0" />
136
+ <element name="simple_action" type="xsd:string" minOccurs="0" />
137
+ <element name="discount_amount" type="xsd:float" minOccurs="0" />
138
+ <element name="website_ids" type="xsd:string" minOccurs="0" />
139
+ </all>
140
+ </complexType>
141
+
142
+ <complexType name="mshopPromotionsListCatalogPromotionsEntityArray">
143
+ <complexContent>
144
+ <restriction base="soapenc:Array">
145
+ <attribute ref="soapenc:arrayType"
146
+ wsdl:arrayType="typens:mshopPromotionsListCatalogPromotionsEntity[]" />
147
+ </restriction>
148
+ </complexContent>
149
+ </complexType>
150
+
151
+ <complexType name="mshopPromotionsCreateCatalogRuleEntity">
152
+ <all>
153
+ <element name="name" type="xsd:string" minOccurs="0" />
154
+ <element name="description" type="xsd:string" minOccurs="0" />
155
+ <element name="from_date" type="xsd:string" minOccurs="0" />
156
+ <element name="to_date" type="xsd:string" minOccurs="0" />
157
+ <element name="conditions_serialized" type="xsd:string"
158
+ minOccurs="0" />
159
+ <element name="actions_serialized" type="xsd:string"
160
+ minOccurs="0" />
161
+ <element name="is_active" type="xsd:int" minOccurs="0" />
162
+ <element name="stop_rules_processing" type="xsd:int"
163
+ minOccurs="0" />
164
+ <element name="sort_order" type="xsd:int" minOccurs="0" />
165
+ <element name="simple_action" type="xsd:string" minOccurs="0" />
166
+ <element name="discount_amount" type="xsd:float" minOccurs="0" />
167
+ </all>
168
+ </complexType>
169
+
170
+ <complexType name="mshopPromotionsListCustomersForRuleEntity">
171
+ <all>
172
+ <element name="id" type="xsd:int" minOccurs="0" />
173
+ <element name="email" type="xsd:string" minOccurs="0" />
174
+ <element name="name" type="xsd:string" minOccurs="0" />
175
+
176
+ </all>
177
+ </complexType>
178
+
179
+ <complexType name="mshopPromotionsListCustomersForRuleEntityArray">
180
+ <complexContent>
181
+ <restriction base="soapenc:Array">
182
+ <attribute ref="soapenc:arrayType"
183
+ wsdl:arrayType="typens:mshopPromotionsListCustomersForRuleEntity[]" />
184
+ </restriction>
185
+ </complexContent>
186
+ </complexType>
187
+ <!-- end promotions -->
188
+
189
+ </schema>
190
+ </types>
191
+ <!-- customer credit -->
192
+ <message name="mshopCreditStopRequest">
193
+ <part name="sessionId" type="xsd:string" />
194
+ <part name="email" type="xsd:string" />
195
+ <part name="website_id" type="xsd:string" />
196
+ </message>
197
+
198
+ <message name="mshopCreditStopResponse">
199
+ <part name="status" type="xsd:boolean" />
200
+ </message>
201
+
202
+ <message name="mshopCreditUnblockRequest">
203
+ <part name="sessionId" type="xsd:string" />
204
+ <part name="email" type="xsd:string" />
205
+ <part name="website_id" type="xsd:string" />
206
+ </message>
207
+
208
+ <message name="mshopCreditUnblockResponse">
209
+ <part name="status" type="xsd:boolean" />
210
+ </message>
211
+
212
+ <!-- end customer credit -->
213
+
214
+ <!-- mamut -->
215
+
216
+ <message name="mshopMamutSetMamutIdRequest">
217
+ <part name="sessionId" type="xsd:string" />
218
+ <part name="mamutId4" type="xsd:int" />
219
+ <part name="customerIds" type="xsd:int" />
220
+ </message>
221
+
222
+ <message name="mshopMamutSetMamutIdResponse">
223
+ <part name="bool" type="xsd:boolean" />
224
+ </message>
225
+
226
+ <message name="mshopMamutRemoveMamutMappingRequest">
227
+ <part name="sessionId" type="xsd:string" />
228
+ <part name="mamutId" type="xsd:int" />
229
+ <part name="customerId" type="xsd:int" />
230
+ </message>
231
+
232
+ <message name="mshopMamutRemoveMamutMappingResponse">
233
+ <part name="status" type="xsd:boolean" />
234
+ </message>
235
+
236
+
237
+ <!-- customer -->
238
+ <message name="mshopMCustomerUpdatePreferedLocaleRequest">
239
+ <part name="sessionId" type="xsd:string" />
240
+ <part name="mamutId" type="xsd:int" />
241
+ <part name="preferedLocale" type="xsd:string" />
242
+ <!-- <part name="taxclassid" type="xsd:int" /> -->
243
+ </message>
244
+
245
+ <message name="mshopMCustomerUpdatePreferedLocaleResponse">
246
+ <part name="bool" type="xsd:boolean" />
247
+ </message>
248
+
249
+ <message name="mshopMCustomerCreateCustomerGroupRequest">
250
+ <part name="sessionId" type="xsd:string" />
251
+ <part name="groupname" type="xsd:string" />
252
+ <!-- <part name="taxclassid" type="xsd:int" /> -->
253
+ </message>
254
+
255
+ <message name="mshopMCustomerUpdateRequest">
256
+ <part name="sessionId" type="xsd:string" />
257
+ <part name="customer_id" type="xsd:int" />
258
+ <part name="customerData" type="typens:mshopCustomerUpdateEntity" />
259
+ <part name="addressBillingData" type="typens:mshopAddressUpdateEntityForDefaultBillingAddress" />
260
+ <part name="addressShippingData" type="typens:mshopAddressUpdateEntityForDefaultShippingAddress" />
261
+ </message>
262
+
263
+ <message name="mshopMCustomerCreateCustomerGroupResponse">
264
+ <part name="bool" type="xsd:boolean" />
265
+ </message>
266
+
267
+ <message name="mshopMCustomerUpdateResponse">
268
+ <part name="bool" type="xsd:boolean" />
269
+ </message>
270
+
271
+ <message name="mshopMCustomerAssignCustomerToGroupRequest">
272
+ <part name="sessionId" type="xsd:string" />
273
+ <part name="customerid" type="xsd:int" />
274
+ <part name="groupid" type="xsd:int" />
275
+ </message>
276
+
277
+ <message name="mshopMCustomerAssignCustomerToGroupResponse">
278
+ <part name="bool" type="xsd:boolean" />
279
+ </message>
280
+
281
+ <message name="mshopMCustomerGetCustomersChangedSinceRequest">
282
+ <part name="sessionId" type="xsd:string" />
283
+ <part name="date" type="xsd:string" />
284
+ </message>
285
+
286
+ <message name="mshopMCustomerGetCustomersChangedSinceResponse">
287
+ <part name="result" type="typens:ArrayOfInt" />
288
+ </message>
289
+
290
+ <message name="mshopMCustomerCreateRequest">
291
+ <part name="sessionId" type="xsd:string" />
292
+ <!-- <part name="customerData" type="typens:customerCustomerCreateEntity" /> -->
293
+ <part name="customerData" type="typens:mshopCustomerUpdateEntity" />
294
+ <part name="addressBillingData" type="typens:mshopAddressUpdateEntityForDefaultBillingAddress" />
295
+ <part name="addressShippingData" type="typens:mshopAddressUpdateEntityForDefaultShippingAddress" />
296
+ </message>
297
+
298
+ <message name="mshopMCustomerCreateResponse">
299
+ <part name="customerId" type="xsd:string" />
300
+ </message>
301
+
302
+ <!-- end customer -->
303
+
304
+ <!-- promotions -->
305
+
306
+ <message name="mshopPromotionsListCatalogPromotionsRequest">
307
+ <part name="sessionId" type="xsd:string" />
308
+ </message>
309
+
310
+ <message name="mshopPromotionsListCatalogPromotionsResponse">
311
+ <part name="catalogPromotions"
312
+ type="typens:mshopPromotionsListCatalogPromotionsEntityArray" />
313
+ </message>
314
+
315
+ <message name="mshopPromotionsCreateCatalogRuleRequest">
316
+ <part name="sessionId" type="xsd:string" />
317
+ <part name="ruleData" type="typens:mshopPromotionsCreateCatalogRuleEntity" />
318
+ <part name="customerGroupIds" type="typens:ArrayOfString" />
319
+ <part name="websiteIds" type="typens:ArrayOfString" />
320
+ <part name="applyRule" type="xsd:int" />
321
+ <part name="mamutID" type="xsd:int" />
322
+ </message>
323
+
324
+ <message name="mshopPromotionsCreateCatalogRuleResponse">
325
+ <part name="ruleId" type="xsd:int" />
326
+ </message>
327
+
328
+ <message name="mshopPromotionsAddIndividualCustomersRequest">
329
+ <part name="sessionId" type="xsd:string" />
330
+ <part name="customerIds" type="typens:ArrayOfString" />
331
+ <part name="ruleId" type="xsd:int" />
332
+ </message>
333
+
334
+ <message name="mshopPromotionsAddIndividualCustomersResponse">
335
+ <part name="status" type="xsd:string" />
336
+ </message>
337
+
338
+ <message name="mshopPromotionsRemoveIndividualCustomersRequest">
339
+ <part name="sessionId" type="xsd:string" />
340
+ <part name="customerIds" type="typens:ArrayOfString" />
341
+ <part name="ruleId" type="xsd:int" />
342
+ </message>
343
+
344
+ <message name="mshopPromotionsRemoveIndividualCustomersResponse">
345
+ <part name="status" type="xsd:string" />
346
+ </message>
347
+
348
+ <message name="mshopPromotionsListCustomersForRuleRequest">
349
+ <part name="sessionId" type="xsd:string" />
350
+ <part name="ruleId" type="xsd:int" />
351
+ </message>
352
+
353
+ <message name="mshopPromotionsListCustomersForRuleResponse">
354
+ <part name="catalogPromotions"
355
+ type="typens:mshopPromotionsListCustomersForRuleEntityArray" />
356
+ </message>
357
+
358
+ <message name="mshopPromotionsUpdateCatalogRuleRequest">
359
+ <part name="sessionId" type="xsd:string" />
360
+ <part name="ruleId" type="xsd:int" />
361
+ <part name="ruleData" type="typens:mshopPromotionsCreateCatalogRuleEntity" />
362
+ <part name="customerGroupIds" type="typens:ArrayOfString" />
363
+ <part name="websiteIds" type="typens:ArrayOfString" />
364
+ <part name="applyRule" type="xsd:int" />
365
+ <part name="mamutID" type="xsd:int" />
366
+ </message>
367
+
368
+ <message name="mshopPromotionsUpdateCatalogRuleResponse">
369
+ <part name="status" type="xsd:string" />
370
+ </message>
371
+
372
+ <message name="mshopPromotionsCheckCreateFixedPriceForCustomerRequest">
373
+ <part name="sessionId" type="xsd:string" />
374
+ <part name="mamutRuleId" type="xsd:int" />
375
+ <part name="mamutCustomerId" type="xsd:int" />
376
+ <part name="productSku" type="xsd:string" />
377
+ <part name="price" type="xsd:double" />
378
+ </message>
379
+
380
+ <message name="mshopPromotionsCheckCreateFixedPriceForCustomerResponse">
381
+ <part name="rule_id" type="xsd:int" />
382
+ </message>
383
+
384
+ <message name="mshopPromotionsCheckCreateDiscountForCustomerRequest">
385
+ <part name="sessionId" type="xsd:string" />
386
+ <part name="mamutRuleId" type="xsd:int" />
387
+ <part name="mamutCustomerId" type="xsd:int" />
388
+ <part name="productSku" type="xsd:string" />
389
+ <part name="discountPercentage" type="xsd:double" />
390
+ </message>
391
+
392
+ <message name="mshopPromotionsCheckCreateDiscountForCustomerResponse">
393
+ <part name="rule_id" type="xsd:int" />
394
+ </message>
395
+
396
+
397
+ <message name="mshopPromotionsCheckCreateDiscountCategoryForCustomerRequest">
398
+ <part name="sessionId" type="xsd:string" />
399
+ <part name="mamutRuleId" type="xsd:int" />
400
+ <part name="mamutCustomerId" type="xsd:int" />
401
+ <part name="categoryId" type="xsd:int" />
402
+ <part name="discountPercentage" type="xsd:double" />
403
+ </message>
404
+
405
+ <message
406
+ name="mshopPromotionsCheckCreateDiscountCategoryForCustomerResponse">
407
+ <part name="rule_id" type="xsd:int" />
408
+ <!-- <part name="rule_id" type="xsd:string" /> -->
409
+ </message>
410
+
411
+ <message name="mshopPromotionsCheckCreateFixedPriceForCustomerGroupRequest">
412
+ <part name="sessionId" type="xsd:string" />
413
+ <part name="mamutRuleId" type="xsd:int" />
414
+ <part name="customerGroup" type="xsd:string" />
415
+ <part name="productSku" type="xsd:string" />
416
+ <part name="price" type="xsd:double" />
417
+ </message>
418
+
419
+ <message name="mshopPromotionsCheckCreateFixedPriceForCustomerGroupResponse">
420
+ <part name="rule_id" type="xsd:int" />
421
+ </message>
422
+
423
+ <message name="mshopPromotionsCheckCreateDiscountForCustomerGroupRequest">
424
+ <part name="sessionId" type="xsd:string" />
425
+ <part name="mamutRuleId" type="xsd:int" />
426
+ <part name="customerGroup" type="xsd:string" />
427
+ <part name="productSku" type="xsd:string" />
428
+ <part name="discountPercentage" type="xsd:double" />
429
+ </message>
430
+
431
+ <message name="mshopPromotionsCheckCreateDiscountForCustomerGroupResponse">
432
+ <part name="rule_id" type="xsd:int" />
433
+ </message>
434
+
435
+ <message
436
+ name="mshopPromotionsCheckCreateDiscountCategoryForCustomerGroupRequest">
437
+ <part name="sessionId" type="xsd:string" />
438
+ <part name="mamutRuleId" type="xsd:int" />
439
+ <part name="customerGroup" type="xsd:string" />
440
+ <part name="categoryId" type="xsd:int" />
441
+ <part name="discountPercentage" type="xsd:double" />
442
+ </message>
443
+
444
+ <message
445
+ name="mshopPromotionsCheckCreateDiscountCategoryForCustomerGroupResponse">
446
+ <part name="rule_id" type="xsd:int" />
447
+ </message>
448
+
449
+ <message name="mshopPromotionsDeleteDiscountRulesExceptRequest">
450
+ <part name="sessionId" type="xsd:string" />
451
+ <part name="mamutRuleIds" type="typens:ArrayOfString" />
452
+ </message>
453
+
454
+ <message name="mshopPromotionsDeleteDiscountRulesExceptResponse">
455
+ <part name="bool" type="xsd:boolean" />
456
+ </message>
457
+
458
+ <message name="mshopPromotionsCheckCreateDefaultDiscountForCustomerRequest">
459
+ <part name="sessionId" type="xsd:string" />
460
+ <part name="mamutRuleId" type="xsd:int" />
461
+ <part name="mamutCustomerId" type="xsd:int" />
462
+ <part name="discountPercentage" type="xsd:double" />
463
+ </message>
464
+
465
+ <message name="mshopPromotionsCheckCreateDefaultDiscountForCustomerResponse">
466
+ <part name="rule_id" type="xsd:int" />
467
+ </message>
468
+
469
+ <message name="mshopPromotionsApplyDiscountRulesRequest">
470
+ <part name="sessionId" type="xsd:string" />
471
+ </message>
472
+
473
+ <message name="mshopPromotionsApplyDiscountRulesResponse">
474
+ <part name="status" type="xsd:boolean" />
475
+ </message>
476
+
477
+
478
+ <!-- end promotions -->
479
+
480
+ <portType name="{{var wsdl.handler}}PortType">
481
+
482
+ <!-- customer credit -->
483
+ <operation name="mshopCreditStop">
484
+ <documentation>Blocks customer from shopping in magento</documentation>
485
+ <input message="typens:mshopCreditStopRequest" />
486
+ <output message="typens:mshopCreditStopResponse" />
487
+ </operation>
488
+
489
+ <operation name="mshopCreditUnblock">
490
+ <documentation>Removes customer shopping ban in magento</documentation>
491
+ <input message="typens:mshopCreditUnblockRequest" />
492
+ <output message="typens:mshopCreditUnblockResponse" />
493
+ </operation>
494
+
495
+ <!-- end customer credit -->
496
+
497
+ <!-- mamut -->
498
+
499
+ <operation name="mshopMamutSetMamutId">
500
+ <documentation>Set the mamut ID for given customer ID</documentation>
501
+ <input message="typens:mshopMamutSetMamutIdRequest" />
502
+ <output message="typens:mshopMamutSetMamutIdResponse" />
503
+ </operation>
504
+
505
+ <operation name="mshopMamutRemoveMamutMapping">
506
+ <documentation>Remove mamut to customer mapping</documentation>
507
+ <input message="typens:mshopMamutRemoveMamutMappingRequest" />
508
+ <output message="typens:mshopMamutRemoveMamutMappingResponse" />
509
+ </operation>
510
+
511
+
512
+
513
+
514
+
515
+ <!-- end mamut -->
516
+
517
+ <!-- customer -->
518
+ <operation name="mshopMCustomerUpdatePreferedLocale">
519
+ <documentation>Updates the prefered locale for the given customer
520
+ </documentation>
521
+ <input message="typens:mshopMCustomerUpdatePreferedLocaleRequest" />
522
+ <output message="typens:mshopMCustomerUpdatePreferedLocaleResponse" />
523
+ </operation>
524
+
525
+ <operation name="mshopMCustomerCreateCustomerGroup">
526
+ <documentation>Create Customer Group by Name for given Tax Class Id
527
+ </documentation>
528
+ <input message="typens:mshopMCustomerCreateCustomerGroupRequest" />
529
+ <output message="typens:mshopMCustomerCreateCustomerGroupResponse" />
530
+ </operation>
531
+
532
+ <operation name="mshopMCustomerUpdate">
533
+ <documentation>Update customer information and invoice and billing adress
534
+ </documentation>
535
+ <input message="typens:mshopMCustomerUpdateRequest" />
536
+ <output message="typens:mshopMCustomerUpdateResponse" />
537
+ </operation>
538
+
539
+ <operation name="mshopMCustomerAssignCustomerToGroup">
540
+ <documentation>Assigns a customer to a given customer group
541
+ </documentation>
542
+ <input message="typens:mshopMCustomerAssignCustomerToGroupRequest" />
543
+ <output message="typens:mshopMCustomerAssignCustomerToGroupResponse" />
544
+ </operation>
545
+
546
+ <operation name="mshopMCustomerGetCustomersChangedSince">
547
+ <documentation>Get list of customers update since
548
+ </documentation>
549
+ <input message="typens:mshopMCustomerGetCustomersChangedSinceRequest" />
550
+ <output message="typens:mshopMCustomerGetCustomersChangedSinceResponse" />
551
+ </operation>
552
+
553
+ <operation name="mshopMCustomerCreate">
554
+ <documentation>Create customer with invoice and billing address
555
+ </documentation>
556
+ <input message="typens:mshopMCustomerCreateRequest" />
557
+ <output message="typens:mshopMCustomerCreateResponse" />
558
+ </operation>
559
+ <!-- end customer -->
560
+
561
+
562
+ <!-- promotions -->
563
+
564
+ <operation name="mshopPromotionsCheckCreateFixedPriceForCustomer">
565
+ <documentation>Create Fixed Price For Customer</documentation>
566
+ <input
567
+ message="typens:mshopPromotionsCheckCreateFixedPriceForCustomerRequest" />
568
+ <output
569
+ message="typens:mshopPromotionsCheckCreateFixedPriceForCustomerResponse" />
570
+ </operation>
571
+
572
+ <operation name="mshopPromotionsCheckCreateDiscountForCustomer">
573
+ <documentation>Create Discount For Customer</documentation>
574
+ <input message="typens:mshopPromotionsCheckCreateDiscountForCustomerRequest" />
575
+ <output
576
+ message="typens:mshopPromotionsCheckCreateDiscountForCustomerResponse" />
577
+ </operation>
578
+
579
+ <operation name="mshopPromotionsCheckCreateDiscountCategoryForCustomer">
580
+ <documentation>Create Discount For Customer For Given Category
581
+ </documentation>
582
+ <input
583
+ message="typens:mshopPromotionsCheckCreateDiscountCategoryForCustomerRequest" />
584
+ <output
585
+ message="typens:mshopPromotionsCheckCreateDiscountCategoryForCustomerResponse" />
586
+ </operation>
587
+
588
+ <operation name="mshopPromotionsCheckCreateFixedPriceForCustomerGroup">
589
+ <documentation>Create fixed price for customer group</documentation>
590
+ <input
591
+ message="typens:mshopPromotionsCheckCreateFixedPriceForCustomerGroupRequest" />
592
+ <output
593
+ message="typens:mshopPromotionsCheckCreateFixedPriceForCustomerGroupResponse" />
594
+ </operation>
595
+
596
+ <operation name="mshopPromotionsCheckCreateDiscountForCustomerGroup">
597
+ <documentation>Create discount for customer group</documentation>
598
+ <input
599
+ message="typens:mshopPromotionsCheckCreateDiscountForCustomerGroupRequest" />
600
+ <output
601
+ message="typens:mshopPromotionsCheckCreateDiscountForCustomerGroupResponse" />
602
+ </operation>
603
+
604
+ <operation
605
+ name="mshopPromotionsCheckCreateDiscountCategoryForCustomerGroup">
606
+ <documentation>Create discount on category for customer group
607
+ </documentation>
608
+ <input
609
+ message="typens:mshopPromotionsCheckCreateDiscountCategoryForCustomerGroupRequest" />
610
+ <output
611
+ message="typens:mshopPromotionsCheckCreateDiscountCategoryForCustomerGroupResponse" />
612
+ </operation>
613
+
614
+
615
+ <operation name="mshopPromotionsDeleteDiscountRulesExcept">
616
+ <documentation>Delete Discount Rules Except Passed</documentation>
617
+ <input message="typens:mshopPromotionsDeleteDiscountRulesExceptRequest" />
618
+ <output message="typens:mshopPromotionsDeleteDiscountRulesExceptResponse" />
619
+ </operation>
620
+
621
+ <operation name="mshopPromotionsCheckCreateDefaultDiscountForCustomer">
622
+ <documentation>Create rule for defualt discount on all product for customer</documentation>
623
+ <input message="typens:mshopPromotionsCheckCreateDefaultDiscountForCustomerRequest" />
624
+ <output message="typens:mshopPromotionsCheckCreateDefaultDiscountForCustomerResponse" />
625
+ </operation>
626
+
627
+ <operation name="mshopPromotionsApplyDiscountRules">
628
+ <documentation>Apply Discount Rules</documentation>
629
+ <input message="typens:mshopPromotionsApplyDiscountRulesRequest" />
630
+ <output message="typens:mshopPromotionsApplyDiscountRulesResponse" />
631
+ </operation>
632
+ <!-- end promotions -->
633
+ </portType>
634
+ <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
635
+ <soap:binding style="rpc"
636
+ transport="http://schemas.xmlsoap.org/soap/http" />
637
+
638
+ <!-- Customer credit operations -->
639
+ <operation name="mshopCreditStop">
640
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
641
+ <input>
642
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
643
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
644
+ </input>
645
+ <output>
646
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
647
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
648
+ </output>
649
+ </operation>
650
+
651
+ <operation name="mshopCreditUnblock">
652
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
653
+ <input>
654
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
655
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
656
+ </input>
657
+ <output>
658
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
659
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
660
+ </output>
661
+ </operation>
662
+ <!-- End customer credit operations -->
663
+
664
+ <!-- prmotions operations -->
665
+
666
+ <operation name="mshopPromotionsCheckCreateFixedPriceForCustomer">
667
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
668
+ <input>
669
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
670
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
671
+ </input>
672
+ <output>
673
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
674
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
675
+ </output>
676
+ </operation>
677
+
678
+ <operation name="mshopPromotionsCheckCreateDiscountForCustomer">
679
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
680
+ <input>
681
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
682
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
683
+ </input>
684
+ <output>
685
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
686
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
687
+ </output>
688
+ </operation>
689
+
690
+ <operation name="mshopPromotionsCheckCreateDiscountCategoryForCustomer">
691
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
692
+ <input>
693
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
694
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
695
+ </input>
696
+ <output>
697
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
698
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
699
+ </output>
700
+ </operation>
701
+
702
+ <operation name="mshopPromotionsCheckCreateFixedPriceForCustomerGroup">
703
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
704
+ <input>
705
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
706
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
707
+ </input>
708
+ <output>
709
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
710
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
711
+ </output>
712
+ </operation>
713
+
714
+ <operation name="mshopPromotionsCheckCreateDiscountForCustomerGroup">
715
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
716
+ <input>
717
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
718
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
719
+ </input>
720
+ <output>
721
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
722
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
723
+ </output>
724
+ </operation>
725
+
726
+ <operation
727
+ name="mshopPromotionsCheckCreateDiscountCategoryForCustomerGroup">
728
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
729
+ <input>
730
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
731
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
732
+ </input>
733
+ <output>
734
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
735
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
736
+ </output>
737
+ </operation>
738
+
739
+ <operation name="mshopPromotionsDeleteDiscountRulesExcept">
740
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
741
+ <input>
742
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
743
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
744
+ </input>
745
+ <output>
746
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
747
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
748
+ </output>
749
+ </operation>
750
+
751
+ <operation name="mshopPromotionsCheckCreateDefaultDiscountForCustomer">
752
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
753
+ <input>
754
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
755
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
756
+ </input>
757
+ <output>
758
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
759
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
760
+ </output>
761
+ </operation>
762
+
763
+
764
+ <operation name="mshopPromotionsApplyDiscountRules">
765
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
766
+ <input>
767
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
768
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
769
+ </input>
770
+ <output>
771
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
772
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
773
+ </output>
774
+ </operation>
775
+
776
+
777
+ <!-- end prmotions operations -->
778
+
779
+ <!-- mamut operations -->
780
+ <operation name="mshopMamutSetMamutId">
781
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
782
+ <input>
783
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
784
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
785
+ </input>
786
+ <output>
787
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
788
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
789
+ </output>
790
+ </operation>
791
+ <operation name="mshopMamutRemoveMamutMapping">
792
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
793
+ <input>
794
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
795
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
796
+ </input>
797
+ <output>
798
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
799
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
800
+ </output>
801
+ </operation>
802
+
803
+
804
+
805
+ <!-- customer operations -->
806
+
807
+ <operation name="mshopMCustomerUpdatePreferedLocale">
808
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
809
+ <input>
810
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
811
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
812
+ </input>
813
+ <output>
814
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
815
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
816
+ </output>
817
+ </operation>
818
+
819
+ <operation name="mshopMCustomerCreateCustomerGroup">
820
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
821
+ <input>
822
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
823
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
824
+ </input>
825
+ <output>
826
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
827
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
828
+ </output>
829
+ </operation>
830
+
831
+ <operation name="mshopMCustomerUpdate">
832
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
833
+ <input>
834
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
835
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
836
+ </input>
837
+ <output>
838
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
839
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
840
+ </output>
841
+ </operation>
842
+
843
+ <operation name="mshopMCustomerAssignCustomerToGroup">
844
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
845
+ <input>
846
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
847
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
848
+ </input>
849
+ <output>
850
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
851
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
852
+ </output>
853
+ </operation>
854
+
855
+ <operation name="mshopMCustomerGetCustomersChangedSince">
856
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
857
+ <input>
858
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
859
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
860
+ </input>
861
+ <output>
862
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
863
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
864
+ </output>
865
+ </operation>
866
+
867
+ <operation name="mshopMCustomerCreate">
868
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
869
+ <input>
870
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
871
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
872
+ </input>
873
+ <output>
874
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
875
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
876
+ </output>
877
+ </operation>
878
+
879
+ <!-- end customer operations -->
880
+ </binding>
881
+ <service name="{{var wsdl.name}}Service">
882
+ <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
883
+ <soap:address location="{{var wsdl.url}}" />
884
+ </port>
885
+ </service>
886
+ </definitions>
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-install-1.2.2.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * new Mamut status
8
+ *
9
+ */
10
+
11
+ $code = 'mshop_mamut';
12
+ $label = "Mamut";
13
+
14
+
15
+ $state = "complete";
16
+ $is_default = 1;
17
+
18
+ $status = Mage::getModel('sales/order_status')->load($code);
19
+ if(!$status->getStatus()){
20
+
21
+ $data = array("is_new"=> 1, "status" => $code, "label" => $label, "store_labels" => Array ());
22
+ $status->setData($data)->setStatus($code);
23
+ try{
24
+ $status->save();
25
+ }catch(Exception $ex){
26
+ Mage::log($ex->getMessage());
27
+
28
+ }
29
+ try{
30
+ $status->assignState($state, $isDefault);
31
+
32
+ }catch(Exception $ex){
33
+ Mage::log($ex->getMessage());
34
+
35
+ }
36
+ }
37
+
38
+ /**
39
+ *
40
+ *
41
+ *
42
+ * Mshop Blocked creation attribute
43
+ *
44
+ */
45
+
46
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
47
+
48
+ //$setup->removeAttribute( 'customer', 'mshop_bloked' );
49
+
50
+ $entityTypeId = $setup->getEntityTypeId('customer');
51
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
52
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
53
+
54
+ $setup->addAttribute('customer', 'mshop_bloked', array(
55
+ 'input' => 'text',
56
+ 'type' => 'int',
57
+ 'label' => 'Mshop Blocked',
58
+ 'visible' => 1,
59
+ 'required' => 0,
60
+ 'user_defined' => 1,
61
+ ));
62
+
63
+ $setup->addAttributeToGroup(
64
+ $entityTypeId,
65
+ $attributeSetId,
66
+ $attributeGroupId,
67
+ 'mshop_bloked',
68
+ '999' //sort_order
69
+ );
70
+
71
+ /*
72
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'mshop_bloked');
73
+ $oAttribute->setData('used_in_forms', array('adminhtml_customer'));
74
+ $oAttribute->save();
75
+ */
76
+
77
+ /* add attribute to order */
78
+ //$installer->addAttribute('order', 'reference_order', array('type'=>'varchar'));
79
+
80
+
81
+ /**
82
+ * creation of two mshop tables
83
+ *
84
+ */
85
+ $installer->run("
86
+ DROP TABLE IF EXISTS {$this->getTable('ecomwise_catalogpromotions_mapping')};
87
+ CREATE TABLE {$this->getTable('ecomwise_catalogpromotions_mapping')} (
88
+ `rule_id` int(11) NOT NULL default '0',
89
+ `mamut_id` int(11) NOT NULL default '0',
90
+ `mamut_rule_id` int(11) NOT NULL default '0',
91
+ UNIQUE KEY `ecomwise_rule_mamut_catalog` (`rule_id`,`mamut_id`)
92
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
93
+
94
+ DROP TABLE IF EXISTS {$this->getTable('ecomwise_customermamut_mapping')};
95
+ CREATE TABLE {$this->getTable('ecomwise_customermamut_mapping')} (
96
+ `customer_id` int(11) NOT NULL default '0',
97
+ `mamut_id` int(11) NOT NULL default '0',
98
+ UNIQUE KEY `ecomwise_mamut_customer` (`mamut_id`,`customer_id`)
99
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
100
+ ");
101
+
102
+
103
+
104
+
105
+
106
+ $installer->endSetup();
107
+
108
+
109
+
110
+
111
+ $installer1 = new Mage_Sales_Model_Mysql4_Setup('core_setup');
112
+
113
+ $installer1->startSetup();
114
+
115
+ $installer1->addAttribute('order', 'reference_order', array('type'=>'varchar'));
116
+
117
+ $installer1->endSetup();
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.0-1.2.1.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ /**
6
+ *
7
+ * Adding attribute to customer entity
8
+ *
9
+ *
10
+ *
11
+ */
12
+
13
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
14
+
15
+ // $setup->removeAttribute( 'customer', 'mshop_bloked' );
16
+
17
+ $entityTypeId = $setup->getEntityTypeId('customer');
18
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
19
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
20
+
21
+ $setup->addAttribute('customer', 'mshop_bloked', array(
22
+ 'input' => 'text',
23
+ 'type' => 'int',
24
+ 'label' => 'Mshop Blocked',
25
+ 'visible' => 1,
26
+ 'required' => 0,
27
+ 'user_defined' => 1,
28
+ ));
29
+
30
+ $setup->addAttributeToGroup(
31
+ $entityTypeId,
32
+ $attributeSetId,
33
+ $attributeGroupId,
34
+ 'mshop_bloked',
35
+ '999' //sort_order
36
+ );
37
+
38
+
39
+
40
+
41
+ $installer->endSetup();
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.1-1.2.2.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ /**
6
+ *
7
+ *
8
+ * Adding new order status
9
+ *
10
+ */
11
+
12
+ $code = 'mshop_mamut';
13
+ $label = "Mamut";
14
+
15
+
16
+ $state = "complete";
17
+ $is_default = 1;
18
+
19
+ $status = Mage::getModel('sales/order_status')->load($code);
20
+ if(!$status->getStatus()){
21
+
22
+ $data = array("is_new"=> 1, "status" => $code, "label" => $label, "store_labels" => Array ());
23
+ $status->setData($data)->setStatus($code);
24
+ try{
25
+ $status->save();
26
+ }catch(Exception $ex){
27
+ Mage::log($ex->getMessage());
28
+
29
+ }
30
+ try{
31
+ $status->assignState($state, $isDefault);
32
+
33
+ }catch(Exception $ex){
34
+ Mage::log($ex->getMessage());
35
+
36
+ }
37
+ }
38
+
39
+ $installer->endSetup();
40
+
41
+
42
+
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.2-1.2.3.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+
6
+ /**
7
+ * creation of mamut contact groups table
8
+ *
9
+ */
10
+
11
+ $installer->run("
12
+ DROP TABLE IF EXISTS {$this->getTable('ecomwise_mamut_contact_groups')};
13
+ CREATE TABLE {$this->getTable('ecomwise_mamut_contact_groups')} (
14
+ `group_id` int(11) NOT NULL AUTO_INCREMENT,
15
+ `mamut_contact_group_name` varchar(255) NOT NULL default '0',
16
+ PRIMARY KEY(group_id)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+ INSERT INTO {$this->getTable('ecomwise_mamut_contact_groups')} (`mamut_contact_group_name`) VALUES('MAMUT NOT LOGGED IN')
19
+ ");
20
+
21
+
22
+ /**
23
+ *
24
+ *
25
+ *
26
+ * mamut contacts groups customer attribute
27
+ *
28
+ */
29
+
30
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
31
+
32
+ //$setup->removeAttribute( 'customer', 'mshop_bloked' );
33
+
34
+ $entityTypeId = $setup->getEntityTypeId('customer');
35
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
36
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
37
+
38
+ $setup->addAttribute('customer', 'mamut_contact_groups', array(
39
+ 'label' => 'Mamut Contact Groups',
40
+ 'type' => 'text',
41
+ 'input' => 'multiselect',
42
+ 'backend' => 'mshopb2b/customerattribute_backend_mamutgroups',
43
+ 'input_renderer' => 'mshopb2b/customerattribute_helper_mamutgroups',
44
+ 'source' => 'mshopb2b/customerattribute_source_mamutgroups',
45
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
46
+ 'visible' => true,
47
+ 'required' => false,
48
+ 'user_defined' => false,
49
+ 'searchable' => false,
50
+ 'filterable' => false,
51
+ 'comparable' => false,
52
+ 'visible_on_front' => false,
53
+ 'visible_in_advanced_search' => false,
54
+ 'unique' => false
55
+
56
+ ));
57
+
58
+
59
+ $setup->addAttributeToGroup(
60
+ $entityTypeId,
61
+ $attributeSetId,
62
+ $attributeGroupId,
63
+ 'mamut_contact_groups',
64
+ '999' //sort_order
65
+ );
66
+
67
+
68
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'mamut_contact_groups');
69
+ $oAttribute->setData('used_in_forms', array('adminhtml_customer'));
70
+ $oAttribute->setData('sort_order', 999);
71
+ $oAttribute->save();
72
+
73
+
74
+ $installer->endSetup();
75
+
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.3-1.2.4.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+
8
+ ALTER TABLE {$this->getTable('ecomwise_customermamut_mapping')}
9
+ CHANGE `customer_id` `customer_id` INT( 10 ) UNSIGNED NOT NULL ;
10
+
11
+ ALTER TABLE {$this->getTable('ecomwise_customermamut_mapping')}
12
+ ADD CONSTRAINT `CUSTOMER_MAMUT_MAPPING_CO_CUSTOM` FOREIGN KEY (`customer_id`)
13
+ REFERENCES {$this->getTable('customer_entity')} (`entity_id`)
14
+ ON DELETE CASCADE ON UPDATE CASCADE;
15
+
16
+
17
+ ");
18
+
19
+ $installer->endSetup();
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.4-1.2.5.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->endSetup();
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.5-1.2.6.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->run("
6
+
7
+ ALTER TABLE {$this->getTable('customer/customer_group')} MODIFY customer_group_code VARCHAR(100) ;
8
+
9
+
10
+ ");
11
+
12
+ $installer->endSetup();
app/code/community/Ecomwise/MshopB2B/sql/mshopb2b_setup/mysql4-upgrade-1.2.6-1.2.7.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Upgrade script for transfering extension from Experius to Ecomwise namesapce
4
+ *
5
+ */
6
+
7
+ $installer = $this;
8
+ $installer->startSetup();
9
+
10
+ //ecomwise_catalogpromotions_mapping table moving
11
+
12
+ if (!$installer->tableExists($installer->getTable('ecomwise_catalogpromotions_mapping'))){
13
+
14
+ $installer->run("
15
+ CREATE TABLE {$this->getTable('ecomwise_catalogpromotions_mapping')} (
16
+ `rule_id` int(11) NOT NULL default '0',
17
+ `mamut_id` int(11) NOT NULL default '0',
18
+ `mamut_rule_id` int(11) NOT NULL default '0',
19
+ UNIQUE KEY `ecomwise_rule_mamut_catalog` (`rule_id`,`mamut_id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+ ");
22
+ }
23
+
24
+
25
+ if ($installer->tableExists($installer->getTable('experius_catalogpromotions_mapping')) && $installer->tableExists($installer->getTable('ecomwise_catalogpromotions_mapping'))) {
26
+
27
+ $installer->run("INSERT INTO {$this->getTable('ecomwise_catalogpromotions_mapping')} (`rule_id`, `mamut_id`, `mamut_rule_id` ) SELECT `rule_id`, `mamut_id`, `mamut_rule_id` FROM {$this->getTable('experius_catalogpromotions_mapping')};");
28
+
29
+ }
30
+
31
+
32
+
33
+ //ecomwise_customermamut_mapping table moving
34
+
35
+ if (!$installer->tableExists($installer->getTable('ecomwise_customermamut_mapping'))){
36
+
37
+ $installer->run("
38
+ CREATE TABLE {$this->getTable('ecomwise_customermamut_mapping')} (
39
+ `customer_id` int(11) NOT NULL default '0',
40
+ `mamut_id` int(11) NOT NULL default '0',
41
+ UNIQUE KEY `ecomwise_mamut_customer` (`mamut_id`,`customer_id`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
43
+ ");
44
+ }
45
+
46
+
47
+ if ($installer->tableExists($installer->getTable('experius_customermamut_mapping')) && $installer->tableExists($installer->getTable('ecomwise_customermamut_mapping'))) {
48
+
49
+ $installer->run("INSERT INTO {$this->getTable('ecomwise_customermamut_mapping')} (`customer_id`, `mamut_id`) SELECT `customer_id`, `mamut_id` FROM {$this->getTable('experius_customermamut_mapping')};");
50
+
51
+ }
52
+
53
+
54
+ //ecomwise_mamut_contact_groups mamut_contact_group_name table moving
55
+
56
+ if (!$installer->tableExists($installer->getTable('ecomwise_mamut_contact_groups'))){
57
+
58
+ $installer->run("
59
+ CREATE TABLE {$this->getTable('ecomwise_mamut_contact_groups')} (
60
+ `group_id` int(11) NOT NULL AUTO_INCREMENT,
61
+ `mamut_contact_group_name` varchar(255) NOT NULL default '0',
62
+ PRIMARY KEY(group_id)
63
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
64
+ ");
65
+ }
66
+
67
+
68
+ if ($installer->tableExists($installer->getTable('experius_mamut_contact_groups')) && $installer->tableExists($installer->getTable('ecomwise_mamut_contact_groups'))) {
69
+
70
+ $installer->run("INSERT INTO {$this->getTable('ecomwise_mamut_contact_groups')} (`group_id`, `mamut_contact_group_name`) SELECT `group_id`, `mamut_contact_group_name` FROM {$this->getTable('experius_mamut_contact_groups')};");
71
+
72
+ }
73
+
74
+
75
+
76
+
77
+
78
+ $installer->endSetup();
app/etc/modules/Ecomwise_MshopB2B.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Ecomwise_MshopB2B>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Ecomwise_MshopB2B>
8
+ </modules>
9
+ </config>
10
+
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ecomwise_MshopB2B</name>
4
+ <version>1.2.7</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL-3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ecomwise MshopB2B</summary>
10
+ <description>Ecomwise MshopB2B</description>
11
+ <notes>1.2.7</notes>
12
+ <authors><author><name>EcomwiseTeam</name><user>Ecomwise</user><email>info@ecomwise.com</email></author></authors>
13
+ <date>2013-03-21</date>
14
+ <time>15:49:54</time>
15
+ <contents><target name="magecommunity"><dir><dir name="Ecomwise"><dir name="MshopB2B"><dir name="Block"><dir name="Adminhtml"><file name="EcomwiseCustomerGrid.php" hash="dbfdbc29f70a50600618b20341bf3a12"/><file name="EcomwisePromoCatalogEditTab.php" hash="785bd9d853cbbbe3caa9d1027060f209"/><file name="EcomwisePromoCatalogGrid.php" hash="52411ba7be17f7b495fb63394ea94d9a"/><dir name="Grid"><dir name="Filter"><file name="Contactgroup.php" hash="cec0beca848789610e25ccd5891766fb"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Shipping"><dir name="Method"><file name="Form.php" hash="c5977ae471de555a2e4a210679c447c4"/></dir></dir></dir></dir></dir></dir><dir name="Customerattribute"><dir name="Helper"><file name="Mamutgroups.php" hash="9036bcaeaa67259bf1d49cb15f4ac5df"/></dir></dir><dir name="Renderers"><file name="CompanyRenderer.php" hash="49f213abd6fe5b4f05909c6901572183"/><file name="GridCatalogCustomer.php" hash="672d9be8ec9667805c1e7a10ccb442ca"/><file name="GridCatalogFilterCustomer.php" hash="15155bb258f4b7e35da0a55b6cd2182f"/><file name="GridCatalogFilterCustomerGroup.php" hash="c2aa13c02966b9ce93faefd81522cf7a"/><file name="GridCatalogRenderer.php" hash="3ca1a30b7d2dc06e21d17c472f5677f2"/><file name="MamutContactRenderer.php" hash="d0db98bfc0815a7432df50ab3db4787b"/><file name="MamutIDRenderer.php" hash="ecd23837baf4112d7b4456668392b74a"/></dir><dir name="System"><dir name="Config"><file name="Version.php" hash="6449b71409bb8cfaea04a70534cff12a"/></dir></dir></dir><dir name="Helper"><file name="Contactgroup.php" hash="4caa21b7e1623f3d1c88125003faff1f"/><file name="Data.php" hash="c9cf85fb852b41baa53e5806efee3903"/></dir><dir name="Model"><dir name="Api"><dir name="Credit"><dir name="Api"><file name="V2.php" hash="d8fdc8c73367da7d9b78abea4d49008e"/></dir><file name="Api.php" hash="de038c9fbee92d85e201a53b51e0f9e5"/></dir><dir name="Customer"><dir name="Api"><file name="V2.php" hash="b41cb49d04a3e134c3fefa43545fae9a"/></dir><file name="Api.php" hash="0c7646cd225b7fc6cf17595e842f8ecb"/></dir><dir name="Mamut"><dir name="Api"><file name="V2.php" hash="118ed9a79c1a2d3f639caf638d06768d"/></dir><file name="Api.php" hash="19b4d27f36359544da44c3be58e49b46"/></dir><dir name="Promotions"><dir name="Api"><file name="V2.php" hash="62bee863ead7b665da1256ea0a6804ec"/></dir><file name="Api.php" hash="1866793a8f31a231e9699bdd89ee6c9b"/></dir></dir><dir name="Carrier"><file name="Mamutshipping.php" hash="aff9241413d2d1bd5c12fd382dee38ce"/></dir><file name="Catalogpromotions.php" hash="86a9138123b2357b9accaa9d65c10e47"/><dir name="Collections"><file name="RuleCollection.php" hash="48dbee3276cce0cf0cfe6d584ca3a9b9"/></dir><dir name="Customer"><file name="Group.php" hash="ac7837ccbb5430b91266e3aed3ade57a"/></dir><dir name="Customerattribute"><dir name="Backend"><file name="Mamutgroups.php" hash="c3b3d585e21fb8e0ae01b49592831b94"/></dir><dir name="Source"><file name="Mamutgroups.php" hash="d59f28e5923c580f530761bb49ca52e2"/></dir></dir><file name="Observer.php" hash="8bc52fd129ef52d979f0a70d4c38c0c6"/><dir name="Payment"><file name="Mamutbilling.php" hash="0dc20d35f0bf8cf33e521074eddf68a0"/></dir><dir name="Rules"><file name="CatalogRule.php" hash="4a4c8737022508d282e47eccf9ffaabc"/><file name="Combine.php" hash="e9cdfef163403a8ca9b4eef9cc656d74"/><file name="MySQL4Rule.php" hash="e29ac19975ad6d73e022f6bd661bbc4e"/></dir><dir name="Sales"><dir name="Tax"><file name="Subtotal.php" hash="560a10b6a7847993968f508837ae5c94"/></dir></dir><dir name="SalesRule"><file name="Validator.php" hash="9707ee7e75d545b565831bb9b10b817f"/></dir></dir><dir name="controllers"><file name="CartController.php" hash="db4fdd17bd474235d58d012bcf387c07"/><file name="OrderController.php" hash="bacc8655b2f54091133146b817182a57"/></dir><dir name="etc"><file name="api.xml" hash="03e4eae894a0e2f14d8cecf32cb4d227"/><file name="config.xml" hash="9b0fb765c69d08b963b2857d0f8921db"/><file name="system.xml" hash="fb154f0a77744f36d31e275fa36aadd8"/><file name="wsdl.xml" hash="8715eef084c6bce978d8544745745d24"/></dir><dir name="sql"><dir name="mshopb2b_setup"><file name="mysql4-install-1.2.2.php" hash="7a5120ba5d69b252f7a7668c11f0ce6a"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="ee25c95cf05cee4ab4ecaaeca9cb381a"/><file name="mysql4-upgrade-1.2.1-1.2.2.php" hash="c1f43a0e7065d3f71d81614e5b81fa41"/><file name="mysql4-upgrade-1.2.2-1.2.3.php" hash="b119975067668f385ec3bbb33be5c86d"/><file name="mysql4-upgrade-1.2.3-1.2.4.php" hash="ca4dba23fec7787507fbe2dc493a1c40"/><file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="80d414d61e6f01d8dcad3c0238434863"/><file name="mysql4-upgrade-1.2.5-1.2.6.php" hash="9d5dacc360981760bcc2af8039c407a0"/><file name="mysql4-upgrade-1.2.6-1.2.7.php" hash="b2de6b3de725a3e41f0bb3b0d98f84ff"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Ecomwise_MshopB2B.xml" hash="5a67f895af3bf287f278b376c6219fe6"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>5.4.8</max></php></required></dependencies>
18
+ </package>