Version Notes
See www.yireo.com/software for details
Download this release
Release Info
Developer | Yireo |
Extension | Yireo_Vm2Mage |
Version | 0.8.215 |
Comparing to | |
See all releases |
Code changes from version 0.7.196 to 0.8.215
- app/code/community/Yireo/Vm2Mage/Helper/Image.php +1 -1
- app/code/community/Yireo/Vm2Mage/Model/Category/Api.php +1 -1
- app/code/community/Yireo/Vm2Mage/Model/Product/Api.php +9 -4
- app/code/community/Yireo/Vm2Mage/Model/User/Api.php +50 -20
- app/code/community/Yireo/Vm2Mage/etc/config.xml +2 -2
- package.xml +2 -2
app/code/community/Yireo/Vm2Mage/Helper/Image.php
CHANGED
@@ -144,7 +144,7 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
144 |
|
145 |
// Check the MD5 sum of this file
|
146 |
if(!empty($md5sum) && md5_file($tmp_file) != $md5sum) {
|
147 |
-
Mage::helper('vm2mage')->debug('ERROR:
|
148 |
return false;
|
149 |
}
|
150 |
|
144 |
|
145 |
// Check the MD5 sum of this file
|
146 |
if(!empty($md5sum) && md5_file($tmp_file) != $md5sum) {
|
147 |
+
Mage::helper('vm2mage')->debug('ERROR: image-download does not match MD5', $tmp_file);
|
148 |
return false;
|
149 |
}
|
150 |
|
app/code/community/Yireo/Vm2Mage/Model/Category/Api.php
CHANGED
@@ -51,7 +51,7 @@ class Yireo_Vm2Mage_Model_Category_Api extends Mage_Catalog_Model_Category_Api
|
|
51 |
}
|
52 |
|
53 |
// Take the parent from Magento
|
54 |
-
$storeId = (isset($data['store_id'])) ? $data['store_id'] : 0;
|
55 |
if($parentId == 0 && !empty($storeId)) {
|
56 |
$parentId = Mage::app()->getStore($storeId)->getRootCategoryId();
|
57 |
}
|
51 |
}
|
52 |
|
53 |
// Take the parent from Magento
|
54 |
+
$storeId = (isset($data['store_id'])) ? (int)$data['store_id'] : 0;
|
55 |
if($parentId == 0 && !empty($storeId)) {
|
56 |
$parentId = Mage::app()->getStore($storeId)->getRootCategoryId();
|
57 |
}
|
app/code/community/Yireo/Vm2Mage/Model/Product/Api.php
CHANGED
@@ -65,6 +65,11 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
65 |
}
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
// Set common attributes
|
69 |
$product->setData($product->getData())
|
70 |
->setStoreId($storeId)
|
@@ -119,14 +124,14 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
119 |
}
|
120 |
|
121 |
// Handle the stock
|
122 |
-
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
|
123 |
-
$stockData = ($stockItem->getId() > 0) ? $stockItem->getData() : array();
|
124 |
if(isset($data['in_stock']) && $data['in_stock'] > 0) {
|
|
|
|
|
125 |
$stockData['qty'] = $data['in_stock'];
|
126 |
$stockData['is_in_stock'] = 1;
|
127 |
$stockData['manage_stock'] = 1;
|
128 |
-
$
|
129 |
-
$product->
|
130 |
}
|
131 |
|
132 |
// Convert the category-IDs
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
// Make sure there is a short-description
|
69 |
+
if(empty($data['short_description'])) {
|
70 |
+
$data['short_description'] = $data['name'];
|
71 |
+
}
|
72 |
+
|
73 |
// Set common attributes
|
74 |
$product->setData($product->getData())
|
75 |
->setStoreId($storeId)
|
124 |
}
|
125 |
|
126 |
// Handle the stock
|
|
|
|
|
127 |
if(isset($data['in_stock']) && $data['in_stock'] > 0) {
|
128 |
+
$stockData = $product->getStockData();
|
129 |
+
Mage::helper('vm2mage')->debug('VirtueMart product stock-data', $stockData);
|
130 |
$stockData['qty'] = $data['in_stock'];
|
131 |
$stockData['is_in_stock'] = 1;
|
132 |
$stockData['manage_stock'] = 1;
|
133 |
+
$stockData['use_config_manage_stock'] = 0;
|
134 |
+
$product->setStockData($stockData);
|
135 |
}
|
136 |
|
137 |
// Convert the category-IDs
|
app/code/community/Yireo/Vm2Mage/Model/User/Api.php
CHANGED
@@ -77,6 +77,9 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
77 |
$customer->setTaxClassId(Mage::getModel('customer/group')->getTaxClassId($data['customer_group_id']));
|
78 |
}
|
79 |
|
|
|
|
|
|
|
80 |
// Set the password (but only if it's a plain MD5-string)
|
81 |
if(preg_match('/^([0-9a-fA-F]{32})$/', $data['password'])) {
|
82 |
$hash = $data['password'].':';
|
@@ -129,52 +132,79 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
129 |
*/
|
130 |
private function saveAddress($customer, $data)
|
131 |
{
|
132 |
-
//
|
|
|
|
|
|
|
|
|
133 |
if(isset($data['address_type']) && strtolower($data['address_type']) == 'st') {
|
134 |
-
$address = $
|
135 |
-
$
|
136 |
-
|
137 |
} else {
|
138 |
-
$address = $
|
139 |
-
$
|
140 |
-
$billing = true;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
// Load the address
|
144 |
if(empty($address)) {
|
145 |
$address = Mage::getModel('customer/address');
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
// Set all needed values
|
149 |
$address
|
150 |
-
->setIsPrimaryBilling($
|
151 |
-
->setIsPrimaryShipping($
|
|
|
|
|
152 |
->setTelephone($data['phone_1'])
|
153 |
->setFirstname($data['first_name'])
|
154 |
->setMiddlename($data['middle_name'])
|
155 |
->setLastname($data['last_name'])
|
156 |
->setCompany($data['company'])
|
157 |
->setFax($data['fax'])
|
158 |
-
->setStreet($
|
159 |
->setCity($data['city'])
|
160 |
->setPostcode($data['zip'])
|
161 |
->setRegion($data['state'])
|
162 |
-
->
|
163 |
;
|
164 |
|
|
|
|
|
|
|
165 |
// Load the country and region
|
166 |
-
$country
|
167 |
-
$region
|
168 |
-
if(!empty($region)) {
|
169 |
-
$address->setRegionId($region->getId());
|
170 |
-
}
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
}
|
175 |
|
|
|
176 |
try {
|
177 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
} catch(Exception $e) {
|
179 |
Mage::helper('vm2mage')->debug('Exception', $e->getMessage());
|
180 |
return array(0, $e->getMessage());
|
77 |
$customer->setTaxClassId(Mage::getModel('customer/group')->getTaxClassId($data['customer_group_id']));
|
78 |
}
|
79 |
|
80 |
+
// Set the taxvat
|
81 |
+
if(!empty($data['taxvat'])) $customer->setTaxvat($data['taxvat']);
|
82 |
+
|
83 |
// Set the password (but only if it's a plain MD5-string)
|
84 |
if(preg_match('/^([0-9a-fA-F]{32})$/', $data['password'])) {
|
85 |
$hash = $data['password'].':';
|
132 |
*/
|
133 |
private function saveAddress($customer, $data)
|
134 |
{
|
135 |
+
// Load both addressses
|
136 |
+
$shippingAddress = $customer->getPrimaryShippingAddress();
|
137 |
+
$billingAddress = $customer->getPrimaryBillingAddress();
|
138 |
+
|
139 |
+
// Determine the address-types
|
140 |
if(isset($data['address_type']) && strtolower($data['address_type']) == 'st') {
|
141 |
+
$address = $shippingAddress;
|
142 |
+
$is_shipping = true;
|
143 |
+
|
144 |
} else {
|
145 |
+
$address = $billingAddress;
|
146 |
+
$is_billing = true;
|
|
|
147 |
}
|
148 |
+
//Mage::helper('vm2mage')->debug('Magento address', $address->debug());
|
149 |
+
|
150 |
+
// Some extra overrides
|
151 |
+
$is_shipping = (empty($shippingAddress)) ? true : false;
|
152 |
+
$is_billing = (empty($billingAddress)) ? true : false;
|
153 |
+
$is_billing = true;
|
154 |
+
$is_shipping = true;
|
155 |
|
156 |
// Load the address
|
157 |
if(empty($address)) {
|
158 |
$address = Mage::getModel('customer/address');
|
159 |
}
|
160 |
|
161 |
+
// Compile the street
|
162 |
+
$street = trim($data['address_1']);
|
163 |
+
if(!empty($data['address_2'])) $street .= "\n".$data['address_2'];
|
164 |
+
|
165 |
+
// Load the country and region
|
166 |
+
$country = Mage::getModel('directory/country')->loadByCode($data['country']);
|
167 |
+
$region = Mage::getModel('directory/region')->loadByCode($data['state'], $country->getId());
|
168 |
+
|
169 |
// Set all needed values
|
170 |
$address
|
171 |
+
->setIsPrimaryBilling($is_billing)
|
172 |
+
->setIsPrimaryShipping($is_shipping)
|
173 |
+
->setIsDefaultBilling($is_billing)
|
174 |
+
->setIsDefaultShipping($is_shipping)
|
175 |
->setTelephone($data['phone_1'])
|
176 |
->setFirstname($data['first_name'])
|
177 |
->setMiddlename($data['middle_name'])
|
178 |
->setLastname($data['last_name'])
|
179 |
->setCompany($data['company'])
|
180 |
->setFax($data['fax'])
|
181 |
+
->setStreet($street)
|
182 |
->setCity($data['city'])
|
183 |
->setPostcode($data['zip'])
|
184 |
->setRegion($data['state'])
|
185 |
+
->setCountry($data['country'])
|
186 |
;
|
187 |
|
188 |
+
// Load the taxvat if available
|
189 |
+
if(!empty($data['taxvat'])) $address->setVatId($data['taxvat']);
|
190 |
+
|
191 |
// Load the country and region
|
192 |
+
if(!empty($country)) $address->setCountryId($country->getId());
|
193 |
+
if(!empty($region)) $address->setRegionId($region->getId());
|
|
|
|
|
|
|
194 |
|
195 |
+
// Set the customer if needed
|
196 |
+
if(!$address->getCustomerId() > 0) $address->setCustomerId($customer->getId());
|
|
|
197 |
|
198 |
+
// Save the address
|
199 |
try {
|
200 |
+
if($address->getId() > 0) {
|
201 |
+
$address->save();
|
202 |
+
} else {
|
203 |
+
$address->save();
|
204 |
+
$customer->addAddress($address);
|
205 |
+
$customer->save();
|
206 |
+
}
|
207 |
+
|
208 |
} catch(Exception $e) {
|
209 |
Mage::helper('vm2mage')->debug('Exception', $e->getMessage());
|
210 |
return array(0, $e->getMessage());
|
app/code/community/Yireo/Vm2Mage/etc/config.xml
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* @author Yireo
|
7 |
* @package Vm2Mage
|
8 |
-
* @copyright Copyright
|
9 |
* @license Yireo EULA (www.yireo.com)
|
10 |
* @link http://www.yireo.com
|
11 |
*/
|
@@ -14,7 +14,7 @@
|
|
14 |
|
15 |
<modules>
|
16 |
<Yireo_Vm2Mage>
|
17 |
-
<version>0.
|
18 |
</Yireo_Vm2Mage>
|
19 |
</modules>
|
20 |
|
5 |
*
|
6 |
* @author Yireo
|
7 |
* @package Vm2Mage
|
8 |
+
* @copyright Copyright 2012
|
9 |
* @license Yireo EULA (www.yireo.com)
|
10 |
* @link http://www.yireo.com
|
11 |
*/
|
14 |
|
15 |
<modules>
|
16 |
<Yireo_Vm2Mage>
|
17 |
+
<version>0.8.215</version>
|
18 |
</Yireo_Vm2Mage>
|
19 |
</modules>
|
20 |
|
package.xml
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<package>
|
3 |
<name>Yireo_Vm2Mage</name>
|
4 |
-
<version>0.
|
5 |
<stability>stable</stability>
|
6 |
<channel>community</channel>
|
7 |
<license uri="http://www.yireo.com/">Open Source License</license>
|
8 |
<summary>See www.yireo.com/software for details</summary>
|
9 |
<description>See www.yireo.com/software for details</description>
|
10 |
<notes>See www.yireo.com/software for details</notes>
|
11 |
-
<date>
|
12 |
<time>00:00:01</time>
|
13 |
<authors>
|
14 |
<author>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<package>
|
3 |
<name>Yireo_Vm2Mage</name>
|
4 |
+
<version>0.8.215</version>
|
5 |
<stability>stable</stability>
|
6 |
<channel>community</channel>
|
7 |
<license uri="http://www.yireo.com/">Open Source License</license>
|
8 |
<summary>See www.yireo.com/software for details</summary>
|
9 |
<description>See www.yireo.com/software for details</description>
|
10 |
<notes>See www.yireo.com/software for details</notes>
|
11 |
+
<date>2012-08-31</date>
|
12 |
<time>00:00:01</time>
|
13 |
<authors>
|
14 |
<author>
|