Yireo_Vm2Mage - Version 0.10.25

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension Yireo_Vm2Mage
Version 0.10.25
Comparing to
See all releases


Code changes from version 0.10.21 to 0.10.25

app/code/community/Yireo/Vm2Mage/Helper/Data.php CHANGED
@@ -78,12 +78,19 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
78
}
79
}
80
81
/*
82
* Helper-method to initialize debugging
83
*
84
- * @param string $string
85
- * @param mixed $mixed
86
- * @return null
87
*/
88
public function initDebug()
89
{
@@ -92,7 +99,6 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
92
return false;
93
}
94
95
- ini_set('display_errors', 1);
96
Mage::setIsDeveloperMode(true);
97
return true;
98
}
@@ -105,7 +111,7 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
105
foreach($array as $name => $value) {
106
if(is_array($value)) {
107
$value = Mage::helper('vm2mage')->encode($value);
108
- } elseif(!empty($value)) {
109
$value = base64_encode($value);
110
}
111
78
}
79
}
80
81
+ /*
82
+ * Helper-method to initialize settings
83
+ */
84
+ public function init()
85
+ {
86
+ ini_set('display_errors', 1);
87
+ error_reporting(E_ALL & ~E_NOTICE);
88
+ }
89
+
90
/*
91
* Helper-method to initialize debugging
92
*
93
+ * @return boolean
94
*/
95
public function initDebug()
96
{
99
return false;
100
}
101
102
Mage::setIsDeveloperMode(true);
103
return true;
104
}
111
foreach($array as $name => $value) {
112
if(is_array($value)) {
113
$value = Mage::helper('vm2mage')->encode($value);
114
+ } elseif(!empty($value) && !is_numeric($value)) {
115
$value = base64_encode($value);
116
}
117
app/code/community/Yireo/Vm2Mage/Helper/Image.php CHANGED
@@ -78,6 +78,8 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
78
$hasThumbImage = false;
79
if(is_array($images) && !empty($images)) {
80
foreach($images as $image) {
81
if($image['type'] == 'full_image') $hasFullImage = true;
82
if($image['type'] == 'thumbnail') $hasThumbImage = true;
83
}
78
$hasThumbImage = false;
79
if(is_array($images) && !empty($images)) {
80
foreach($images as $image) {
81
+ if(empty($image['type'])) $image['type'] = null;
82
+
83
if($image['type'] == 'full_image') $hasFullImage = true;
84
if($image['type'] == 'thumbnail') $hasThumbImage = true;
85
}
app/code/community/Yireo/Vm2Mage/Helper/Product.php CHANGED
@@ -176,6 +176,10 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
176
*/
177
public function addCustomOptionToProduct($product, $custom_option)
178
{
179
$name = $custom_option['name'];
180
$values = $custom_option['values'];
181
$ordering = $custom_option['ordering'];
176
*/
177
public function addCustomOptionToProduct($product, $custom_option)
178
{
179
+ if (!isset($custom_option['name'])) {
180
+ return $product;
181
+ }
182
+
183
$name = $custom_option['name'];
184
$values = $custom_option['values'];
185
$ordering = $custom_option['ordering'];
app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php CHANGED
@@ -19,6 +19,8 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
19
*/
20
public function initialize($data = null)
21
{
22
// Check for empty data
23
if(!is_array($data) || empty($data['name'])) {
24
return array(0, "Attribute is not an array");
19
*/
20
public function initialize($data = null)
21
{
22
+ Mage::helper('vm2mage')->init();
23
+
24
// Check for empty data
25
if(!is_array($data) || empty($data['name'])) {
26
return array(0, "Attribute is not an array");
app/code/community/Yireo/Vm2Mage/Model/Category/Api.php CHANGED
@@ -19,6 +19,8 @@ class Yireo_Vm2Mage_Model_Category_Api extends Mage_Catalog_Model_Category_Api
19
*/
20
public function migrate($data= null)
21
{
22
// Check for empty data
23
if(!is_array($data)) {
24
return array(0, "Data is not an array");
19
*/
20
public function migrate($data= null)
21
{
22
+ Mage::helper('vm2mage')->init();
23
+
24
// Check for empty data
25
if(!is_array($data)) {
26
return array(0, "Data is not an array");
app/code/community/Yireo/Vm2Mage/Model/Product/Api.php CHANGED
@@ -19,6 +19,8 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
19
*/
20
public function migrate($data = null)
21
{
22
// Check for empty data
23
if(!is_array($data)) {
24
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
@@ -30,16 +32,16 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
30
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
31
32
// Determine the product-type
33
- if($data['has_children'] > 0 && !empty($data['attributes_sku'])) {
34
$typeId = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE;
35
- } elseif($data['has_children'] > 0) {
36
$typeId = Mage_Catalog_Model_Product_Type::TYPE_GROUPED;
37
} else {
38
$typeId = Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
39
}
40
41
// Determine the children of this product already exist
42
- if($data['has_children'] > 0) {
43
foreach($data['children'] as $child) {
44
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
45
if($childId > 0) {
@@ -178,6 +180,7 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
178
$tierPrices = array();
179
foreach($data['all_prices'] as $price) {
180
181
if($price['price_quantity_start'] < 1) continue;
182
if($price['price_quantity_end'] < 1) continue;
183
@@ -200,19 +203,8 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
200
}
201
202
// Handle the stock
203
- if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) $data['in_stock'] = null;
204
- if(!empty($data['in_stock']) && $data['in_stock'] > 0) {
205
- $stockData = $product->getStockData();
206
- //Mage::helper('vm2mage')->debug('VirtueMart product stock-data', $stockData);
207
- $stockData['qty'] = $data['in_stock'];
208
- $stockData['is_in_stock'] = 1;
209
- $stockData['manage_stock'] = 1;
210
- $stockData['use_config_manage_stock'] = 0;
211
- $product->setStockData($stockData);
212
- } else {
213
- $stockData = $product->getStockData();
214
- $stockData['manage_stock'] = 0;
215
- $product->setStockData($stockData);
216
}
217
218
// Convert the category-IDs
@@ -257,6 +249,26 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
257
return array(0, '['.$sku.'] '.$e->getMessage());
258
}
259
260
// Set the Custom Options
261
if(isset($data['custom_options']) || isset($data['custom_option'])) {
262
19
*/
20
public function migrate($data = null)
21
{
22
+ Mage::helper('vm2mage')->init();
23
+
24
// Check for empty data
25
if(!is_array($data)) {
26
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
32
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
33
34
// Determine the product-type
35
+ if(isset($data['has_children']) && $data['has_children'] > 0 && !empty($data['attributes_sku'])) {
36
$typeId = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE;
37
+ } elseif(isset($data['has_children']) && $data['has_children'] > 0) {
38
$typeId = Mage_Catalog_Model_Product_Type::TYPE_GROUPED;
39
} else {
40
$typeId = Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
41
}
42
43
// Determine the children of this product already exist
44
+ if(isset($data['has_children']) && $data['has_children'] > 0) {
45
foreach($data['children'] as $child) {
46
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
47
if($childId > 0) {
180
$tierPrices = array();
181
foreach($data['all_prices'] as $price) {
182
183
+ if(!isset($price['price_quantity_start'])) continue;
184
if($price['price_quantity_start'] < 1) continue;
185
if($price['price_quantity_end'] < 1) continue;
186
203
}
204
205
// Handle the stock
206
+ if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
207
+ $data['in_stock'] = null;
208
}
209
210
// Convert the category-IDs
249
return array(0, '['.$sku.'] '.$e->getMessage());
250
}
251
252
+ // Set the stock
253
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
254
+ if(!empty($data['in_stock']) && $data['in_stock'] > 0) {
255
+ $stockItem->setData('qty', (int) $data['in_stock']);
256
+ $stockItem->setData('is_in_stock', 1);
257
+ $stockItem->setData('manage_stock', 1);
258
+ $stockItem->setData('use_config_manage_stock', 0);
259
+ } else {
260
+ $stockItem->setData('manage_stock', 0);
261
+ $stockItem->setData('use_config_manage_stock', 0);
262
+ }
263
+
264
+ if(!$stockItem->getId() > 0) {
265
+ $stockItem->setData('stock_id', 1);
266
+ $stockItem->setData('product_id', $product->getId());
267
+ }
268
+
269
+ $stockItem->save();
270
+ $product->save();
271
+
272
// Set the Custom Options
273
if(isset($data['custom_options']) || isset($data['custom_option'])) {
274
app/code/community/Yireo/Vm2Mage/Model/User/Api.php CHANGED
@@ -19,6 +19,8 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
19
*/
20
public function migrate($data = null)
21
{
22
// Option to renew customers or not
23
$renewCustomers = (bool)Mage::getStoreConfig('vm2mage/settings/renew_customers');
24
@@ -110,11 +112,27 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
110
111
// Save the address
112
if(isset($data['addresses']) && !empty($data['addresses'])) {
113
foreach($data['addresses'] as $address) {
114
- $rt = $this->saveAddress($customer, $address, $data);
115
}
116
} else {
117
- $rt = $this->saveAddress($customer, $data);
118
}
119
120
if(!empty($rt)) {
@@ -146,29 +164,31 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
146
/**
147
* Save the customer address
148
*/
149
- private function saveAddress($customer, $data, $customerData)
150
{
151
// Load both addressses
152
$shippingAddress = $customer->getPrimaryShippingAddress();
153
$billingAddress = $customer->getPrimaryBillingAddress();
154
155
// Determine the address-types
156
if(isset($data['address_type']) && strtolower($data['address_type']) == 'st') {
157
$address = $shippingAddress;
158
$is_shipping = true;
159
160
- } else {
161
$address = $billingAddress;
162
$is_billing = true;
163
}
164
165
- Mage::helper('vm2mage')->debug('Magento address', $address->debug());
166
167
- // Some extra overrides
168
- $is_shipping = (empty($shippingAddress)) ? true : false;
169
- $is_billing = (empty($billingAddress)) ? true : false;
170
- $is_billing = true;
171
- $is_shipping = true;
172
173
// Load the address
174
if(empty($address)) {
19
*/
20
public function migrate($data = null)
21
{
22
+ Mage::helper('vm2mage')->init();
23
+
24
// Option to renew customers or not
25
$renewCustomers = (bool)Mage::getStoreConfig('vm2mage/settings/renew_customers');
26
112
113
// Save the address
114
if(isset($data['addresses']) && !empty($data['addresses'])) {
115
+
116
+ // Detect whether there is both a billing-address and a shipping-address
117
+ $hasBilling = false;
118
+ $hasShipping = false;
119
+ foreach($data['addresses'] as $address) {
120
+ if(isset($address['address_type']) && strtolower($address['address_type']) == 'bt') {
121
+ $hasBilling = true;
122
+ }
123
+ if(isset($address['address_type']) && strtolower($address['address_type']) == 'st') {
124
+ $hasShipping = true;
125
+ }
126
+ }
127
+
128
+ // Save the addresses
129
foreach($data['addresses'] as $address) {
130
+ $rt = $this->saveAddress($customer, $address, $data, $hasBilling, $hasShipping);
131
}
132
+
133
+ // Save this single address
134
} else {
135
+ $rt = $this->saveAddress($customer, $data, array(), true, true);
136
}
137
138
if(!empty($rt)) {
164
/**
165
* Save the customer address
166
*/
167
+ private function saveAddress($customer, $data, $customerData, $hasBilling, $hasShipping)
168
{
169
// Load both addressses
170
$shippingAddress = $customer->getPrimaryShippingAddress();
171
$billingAddress = $customer->getPrimaryBillingAddress();
172
173
+ // Defaults
174
+ $is_shipping = ($hasShipping) ? false : true;
175
+ $is_billing = ($hasBilling) ? false : true;
176
+
177
// Determine the address-types
178
if(isset($data['address_type']) && strtolower($data['address_type']) == 'st') {
179
$address = $shippingAddress;
180
$is_shipping = true;
181
182
+ } elseif(isset($data['address_type']) && strtolower($data['address_type']) == 'bt') {
183
$address = $billingAddress;
184
$is_billing = true;
185
}
186
187
+ if(!is_object($address)) {
188
+ $address = Mage::getModel('customer/address');
189
+ }
190
191
+ //Mage::helper('vm2mage')->debug('Magento address', $address->debug());
192
193
// Load the address
194
if(empty($address)) {
app/code/community/Yireo/Vm2Mage/etc/config.xml CHANGED
@@ -14,7 +14,7 @@
14
15
<modules>
16
<Yireo_Vm2Mage>
17
- <version>0.10.21</version>
18
</Yireo_Vm2Mage>
19
</modules>
20
14
15
<modules>
16
<Yireo_Vm2Mage>
17
+ <version>0.10.25</version>
18
</Yireo_Vm2Mage>
19
</modules>
20
package.xml CHANGED
@@ -1,2 +1,2 @@
1
<?xml version="1.0"?>
2
- <package><name>Yireo_Vm2Mage</name><version>0.10.21</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2015-03-18</date><time>6:07:52</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="vm2mage"><file name="check-error.png" hash="6a3c4bbf7dff2e4db08183b14329ef9c"/><file name="check-ok.png" hash="9fb629c79fc4a487088ac4aeeb23e40b"/><file name="check-warning.png" hash="39ccef05471d39a99a8fa2ddf4471d20"/></dir></dir></dir></dir></dir></dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_Vm2Mage.xml" hash="bee76713ff8df9db330a8385b2465041"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="vm2mage"><file name="check.phtml" hash="953b257a96841c5efadac97f0cf6614e"/></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="Vm2Mage"><dir name="sql"><dir name="vm2mage_setup"><file name="mysql4-install-0.10.3.php" hash="853a8f5781d1f91356aefbf7ae954d2b"/><file name="mysql4-install-0.5.4.php" hash="af2d480575e32b4f601c0f3d40e49f01"/><file name="mysql4-upgrade-0.10.2-0.10.3.php" hash="39759a5daed7e92bd3aa50c661c2e287"/></dir></dir><dir name="etc"><file name="api.xml" hash="044835e8aef903ec0eaad068d7b428ae"/><file name="config.xml" hash="a1062a3994b6a86347cbf9f3b5673e6d"/><file name="system.xml" hash="675f2984aa4df1298f753be702171a78"/></dir><dir name="controllers"><file name="IndexController.php" hash="beb4a2afae7c48ab6360ccb0759b96bc"/></dir><dir name="Model"><file name="Observer.php" hash="61fca0f64bc8c994a4cab745a77252e0"/><dir name="Widget"><file name="Api.php" hash="dd313f26b2d2f37ee17f632e9b24b182"/></dir><dir name="User"><file name="Api.php" hash="76057284ea5df759cb81f2b9bba271eb"/></dir><dir name="Rewrite"><dir name="Category"><dir name="Attribute"><dir name="Backend"><file name="Image.php" hash="9880fd05bb4bdbb8fc551ee7cace2e9d"/></dir></dir></dir></dir><dir name="Product"><file name="Api.php" hash="930494c6487bb6fb45d75ae7d5121ca4"/></dir><dir name="Order"><file name="Api.php" hash="0e5c94716fbb347e2fef4b1b0f3d19bc"/></dir><dir name="Category"><file name="Api.php" hash="a401028d1d5535f7efc5603463bf4ba6"/></dir><dir name="Attribute"><file name="Api.php" hash="265e9d32e043889f4e07775926233873"/></dir></dir><dir name="Helper"><file name="Attribute.php" hash="84734510b3170b65e782db7a90f715f9"/><file name="Category.php" hash="2780d3ce633e1f6b8ea345506d0cc89a"/><file name="Data.php" hash="affd62abb2fd7e80b599e063128ab4d6"/><file name="Image.php" hash="26bcd12cc33bd37455416035d7f23907"/><file name="Price.php" hash="2d7253c4d727935c79f8e4d861329fa5"/><file name="Product.php" hash="5bc8ab23906478ccd0df546b36f10c2f"/></dir><dir name="Block"><file name="Check.php" hash="1409b8333e818a532fee3aa88c3a1977"/></dir></dir></dir></dir></dir></dir></target></contents></package>
1
<?xml version="1.0"?>
2
+ <package><name>Yireo_Vm2Mage</name><version>0.10.25</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2015-07-06</date><time>6:16:34</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="vm2mage"><file name="check-error.png" hash="6a3c4bbf7dff2e4db08183b14329ef9c"/><file name="check-ok.png" hash="9fb629c79fc4a487088ac4aeeb23e40b"/><file name="check-warning.png" hash="39ccef05471d39a99a8fa2ddf4471d20"/></dir></dir></dir></dir></dir></dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_Vm2Mage.xml" hash="bee76713ff8df9db330a8385b2465041"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="vm2mage"><file name="check.phtml" hash="953b257a96841c5efadac97f0cf6614e"/></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="Vm2Mage"><dir name="sql"><dir name="vm2mage_setup"><file name="mysql4-install-0.10.3.php" hash="853a8f5781d1f91356aefbf7ae954d2b"/><file name="mysql4-install-0.5.4.php" hash="af2d480575e32b4f601c0f3d40e49f01"/><file name="mysql4-upgrade-0.10.2-0.10.3.php" hash="39759a5daed7e92bd3aa50c661c2e287"/></dir></dir><dir name="etc"><file name="api.xml" hash="044835e8aef903ec0eaad068d7b428ae"/><file name="config.xml" hash="63ca309e8e328cc916cadd290a9bbf22"/><file name="system.xml" hash="675f2984aa4df1298f753be702171a78"/></dir><dir name="controllers"><file name="IndexController.php" hash="beb4a2afae7c48ab6360ccb0759b96bc"/></dir><dir name="Model"><file name="Observer.php" hash="61fca0f64bc8c994a4cab745a77252e0"/><dir name="Widget"><file name="Api.php" hash="dd313f26b2d2f37ee17f632e9b24b182"/></dir><dir name="User"><file name="Api.php" hash="dd49ff1f49914f8554609c2c79307f47"/></dir><dir name="Rewrite"><dir name="Category"><dir name="Attribute"><dir name="Backend"><file name="Image.php" hash="9880fd05bb4bdbb8fc551ee7cace2e9d"/></dir></dir></dir></dir><dir name="Product"><file name="Api.php" hash="d180733f05ae08045eea2525a6117d7f"/></dir><dir name="Order"><file name="Api.php" hash="0e5c94716fbb347e2fef4b1b0f3d19bc"/></dir><dir name="Category"><file name="Api.php" hash="6b3dfea5f56030e735e74338c64d315c"/></dir><dir name="Attribute"><file name="Api.php" hash="aa0e201a5dc42cc7bf9b3d22c060c307"/></dir></dir><dir name="Helper"><file name="Attribute.php" hash="84734510b3170b65e782db7a90f715f9"/><file name="Category.php" hash="2780d3ce633e1f6b8ea345506d0cc89a"/><file name="Data.php" hash="d741bda70c83be536b976b88b31d9bd5"/><file name="Image.php" hash="446b73ea001c92a4850e7e168e2ee842"/><file name="Price.php" hash="2d7253c4d727935c79f8e4d861329fa5"/><file name="Product.php" hash="ca99ba63309b9add9f5bb1f9be2f88da"/></dir><dir name="Block"><file name="Check.php" hash="1409b8333e818a532fee3aa88c3a1977"/></dir></dir></dir></dir></dir></dir></target></contents></package>