Yireo_Vm2Mage - Version 0.10.5

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension Yireo_Vm2Mage
Version 0.10.5
Comparing to
See all releases


Code changes from version 0.10.0 to 0.10.5

Files changed (26) hide show
  1. app/code/community/Yireo/Vm2Mage/Block/Check.php +12 -7
  2. app/code/community/Yireo/Vm2Mage/Helper/Attribute.php +28 -7
  3. app/code/community/Yireo/Vm2Mage/Helper/Category.php +12 -8
  4. app/code/community/Yireo/Vm2Mage/Helper/Data.php +25 -1
  5. app/code/community/Yireo/Vm2Mage/Helper/Image.php +52 -50
  6. app/code/community/Yireo/Vm2Mage/Helper/Price.php +1 -1
  7. app/code/community/Yireo/Vm2Mage/Helper/Product.php +67 -7
  8. app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php +70 -26
  9. app/code/community/Yireo/Vm2Mage/Model/Category/Api.php +15 -11
  10. app/code/community/Yireo/Vm2Mage/Model/Observer.php +1 -1
  11. app/code/community/Yireo/Vm2Mage/Model/Order/Api.php +1 -1
  12. app/code/community/Yireo/Vm2Mage/Model/Product/Api.php +60 -28
  13. app/code/community/Yireo/Vm2Mage/Model/Rewrite/Category/Attribute/Backend/Image.php +37 -0
  14. app/code/community/Yireo/Vm2Mage/Model/User/Api.php +48 -16
  15. app/code/community/Yireo/Vm2Mage/Model/Widget/Api.php +1 -1
  16. app/code/community/Yireo/Vm2Mage/controllers/IndexController.php +1 -1
  17. app/code/community/Yireo/Vm2Mage/etc/api.xml +1 -1
  18. app/code/community/Yireo/Vm2Mage/etc/config.xml +17 -2
  19. app/code/community/Yireo/Vm2Mage/etc/system.xml +78 -0
  20. app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.10.3.php +23 -0
  21. app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.5.4.php +1 -1
  22. app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-upgrade-0.10.2-0.10.3.php +17 -0
  23. package.xml +1 -17
  24. skin/adminhtml/default/default/images/vm2mage/check-error.png +0 -0
  25. skin/adminhtml/default/default/images/vm2mage/check-ok.png +0 -0
  26. skin/adminhtml/default/default/images/vm2mage/check-warning.png +0 -0
app/code/community/Yireo/Vm2Mage/Block/Check.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -165,13 +165,18 @@ class Yireo_Vm2Mage_Block_Check extends Mage_Core_Block_Template
165
  $count = Mage::getResourceModel('customer/customer_collection')->count();
166
  $this->addResult('stats', 'Customers', self::CHECK_OK, 'Customer collection count: '.(int)$count);
167
 
168
- $collection = Mage::getResourceModel('vmorder/order_collection');
169
- if(empty($collection)) {
 
 
 
 
 
 
 
 
170
  $result = self::CHECK_ERROR;
171
- $count = 0;
172
- } else {
173
- $result = self::CHECK_OK;
174
- $count = $collection->count();
175
  }
176
  $this->addResult('stats', 'VmOrder', $result, 'VmOrder order-collection count: '.(int)$count);
177
 
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
165
  $count = Mage::getResourceModel('customer/customer_collection')->count();
166
  $this->addResult('stats', 'Customers', self::CHECK_OK, 'Customer collection count: '.(int)$count);
167
 
168
+ try {
169
+ $collection = Mage::getResourceModel('vmorder/order_collection');
170
+ if(empty($collection)) {
171
+ $result = self::CHECK_ERROR;
172
+ $count = 0;
173
+ } else {
174
+ $result = self::CHECK_OK;
175
+ $count = $collection->count();
176
+ }
177
+ } catch(Exception $e) {
178
  $result = self::CHECK_ERROR;
179
+ $count = -1;
 
 
 
180
  }
181
  $this->addResult('stats', 'VmOrder', $result, 'VmOrder order-collection count: '.(int)$count);
182
 
app/code/community/Yireo/Vm2Mage/Helper/Attribute.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -25,6 +25,7 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
25
  $options = array('value' => array());
26
  $i = 1;
27
  foreach($values as $value) {
 
28
  $index = 'option_'.$i;
29
  $options['value'][$index] = array($value, $value);
30
  $i++;
@@ -32,6 +33,18 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
32
 
33
  return $options;
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  /*
37
  * Method to get an attribute by its code
@@ -42,6 +55,7 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
42
  */
43
  public function getAttributeByCode($attributeCode = null)
44
  {
 
45
  $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attributeCode);
46
  return $attribute;
47
  }
@@ -54,20 +68,27 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
54
  * @param string $attribute_value
55
  * @return Mage_Catalog_Model_Product`
56
  */
57
- public function addAttributeToProduct($product = null, $attribute_code = null, $attribute_value = null)
58
  {
59
- $attribute = Mage::helper('vm2mage/attribute')->getAttributeByCode($attribute_code);
 
60
  if(empty($attribute)) {
61
  return $product;
62
  }
63
 
64
- $options = $attribute->getSource()->getAllOptions();
 
 
 
 
 
 
65
  if(empty($options)) {
66
  return $product;
67
  }
68
 
69
  foreach($options as $option) {
70
- if($option['label'] == $attribute_value) {
71
  $value = $option['value'];
72
  break;
73
  }
@@ -77,12 +98,12 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
77
  return $product;
78
  }
79
 
80
- $method = Mage::helper('vm2mage')->stringToMethod($attribute_code);
81
  if(!empty($method)) {
82
  try {
83
  $product->$method($value);
84
  } catch(Exception $e) {
85
- Mage::helper('vm2mage')->debug('Error when setting attribute "'.$attribute_code.'" on product "'.$product->getName().'"');
86
  }
87
  }
88
 
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
25
  $options = array('value' => array());
26
  $i = 1;
27
  foreach($values as $value) {
28
+ if(empty($value)) continue;
29
  $index = 'option_'.$i;
30
  $options['value'][$index] = array($value, $value);
31
  $i++;
33
 
34
  return $options;
35
  }
36
+
37
+ /*
38
+ * Method to convert the attribute-code
39
+ *
40
+ * @param string $attributeCode
41
+ * @return string
42
+ */
43
+ public function convertAttributeCode($attributeCode = null)
44
+ {
45
+ $attributeCode = preg_replace('/([^a-zA-Z0-9\-\_]+)/', '_', $attributeCode);
46
+ return strtolower($attributeCode);
47
+ }
48
 
49
  /*
50
  * Method to get an attribute by its code
55
  */
56
  public function getAttributeByCode($attributeCode = null)
57
  {
58
+ $attributeCode = Mage::helper('vm2mage/attribute')->convertAttributeCode($attributeCode);
59
  $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attributeCode);
60
  return $attribute;
61
  }
68
  * @param string $attribute_value
69
  * @return Mage_Catalog_Model_Product`
70
  */
71
+ public function addAttributeToProduct($product = null, $attributeCode = null, $attributeValue = null)
72
  {
73
+ $attributeCode = Mage::helper('vm2mage/attribute')->convertAttributeCode($attributeCode);
74
+ $attribute = Mage::helper('vm2mage/attribute')->getAttributeByCode($attributeCode);
75
  if(empty($attribute)) {
76
  return $product;
77
  }
78
 
79
+ try {
80
+ $options = $attribute->getSource()->getAllOptions();
81
+ } catch(Exception $e) {
82
+ Mage::helper('vm2mage')->debug('Error when loading product-options', $e->getMessage());
83
+ return $product;
84
+ }
85
+
86
  if(empty($options)) {
87
  return $product;
88
  }
89
 
90
  foreach($options as $option) {
91
+ if($option['label'] == $attributeValue) {
92
  $value = $option['value'];
93
  break;
94
  }
98
  return $product;
99
  }
100
 
101
+ $method = Mage::helper('vm2mage')->stringToMethod($attributeCode);
102
  if(!empty($method)) {
103
  try {
104
  $product->$method($value);
105
  } catch(Exception $e) {
106
+ Mage::helper('vm2mage')->debug('Error when setting attribute "'.$attributeCode.'" on product "'.$product->getName().'"');
107
  }
108
  }
109
 
app/code/community/Yireo/Vm2Mage/Helper/Category.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -18,13 +18,14 @@ class Yireo_Vm2Mage_Helper_Category extends Yireo_Vm2Mage_Helper_Data
18
  * Method to get the Magento ID belonging to a specific VirtueMart ID
19
  *
20
  * @param int $vm_id
 
21
  * @return int
22
  */
23
- public function getMageId($vm_id)
24
  {
25
  $db = Mage::getSingleton('core/resource')->getConnection('core_read');
26
  $table = Mage::getSingleton('core/resource')->getTableName('vm2mage_categories');
27
- $mage_id = $db->fetchOne( "SELECT `mage_id` FROM `$table` WHERE `vm_id` = '$vm_id'" );
28
  return $mage_id;
29
  }
30
 
@@ -33,19 +34,22 @@ class Yireo_Vm2Mage_Helper_Category extends Yireo_Vm2Mage_Helper_Data
33
  *
34
  * @param int $vm_id
35
  * @param int $mage_id
 
36
  * @return bool
37
  */
38
- public function saveRelation($vm_id = 0, $mage_id = 0)
39
  {
40
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
41
  $table = Mage::getSingleton('core/resource')->getTableName('vm2mage_categories');
42
- $result = $db->fetchOne( "SELECT `mage_id` FROM `$table` WHERE `vm_id` = '$vm_id'" );
 
43
 
44
- if($result) {
45
- $query = "UPDATE `$table` SET `mage_id`='$mage_id' WHERE `vm_id`='$vm_id'";
46
  } else {
47
- $query = "INSERT INTO `$table` SET `vm_id` = '$vm_id', `mage_id`='$mage_id'";
48
  }
 
49
  $db->query($query);
50
  return true;
51
  }
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
18
  * Method to get the Magento ID belonging to a specific VirtueMart ID
19
  *
20
  * @param int $vm_id
21
+ * @param string $migration_code
22
  * @return int
23
  */
24
+ public function getMageId($vm_id, $migration_code = null)
25
  {
26
  $db = Mage::getSingleton('core/resource')->getConnection('core_read');
27
  $table = Mage::getSingleton('core/resource')->getTableName('vm2mage_categories');
28
+ $mage_id = $db->fetchOne( "SELECT `mage_id` FROM `$table` WHERE `vm_id` = '$vm_id' AND `migration_code` = '$migration_code'" );
29
  return $mage_id;
30
  }
31
 
34
  *
35
  * @param int $vm_id
36
  * @param int $mage_id
37
+ * @param string $migration_code
38
  * @return bool
39
  */
40
+ public function saveRelation($vm_id = 0, $mage_id = 0, $migration_code = null)
41
  {
42
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
43
  $table = Mage::getSingleton('core/resource')->getTableName('vm2mage_categories');
44
+ $query = "SELECT `mage_id` FROM `$table` WHERE `vm_id` = '$vm_id' AND `migration_code` = '$migration_code'";
45
+ $result = $db->fetchOne($query);
46
 
47
+ if(!empty($result)) {
48
+ $query = "UPDATE `$table` SET `mage_id`='$mage_id' WHERE `vm_id`='$vm_id' AND `migration_code` = '$migration_code'";
49
  } else {
50
+ $query = "INSERT INTO `$table` SET `vm_id` = '$vm_id', `mage_id`='$mage_id', `migration_code` = '$migration_code'";
51
  }
52
+
53
  $db->query($query);
54
  return true;
55
  }
app/code/community/Yireo/Vm2Mage/Helper/Data.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -62,6 +62,11 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
62
  */
63
  public function debug($string, $mixed = null)
64
  {
 
 
 
 
 
65
  // Construct the debug-string
66
  if($mixed) {
67
  $string .= ': '.var_export($mixed, true);
@@ -73,6 +78,25 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
73
  }
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /*
77
  * Recursive function to encode a value
78
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
62
  */
63
  public function debug($string, $mixed = null)
64
  {
65
+ // Disable by setting
66
+ if(Mage::getStoreConfig('vm2mage/settings/debug_log') == 0) {
67
+ return false;
68
+ }
69
+
70
  // Construct the debug-string
71
  if($mixed) {
72
  $string .= ': '.var_export($mixed, true);
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
+ {
90
+ // Disable by setting
91
+ if(Mage::getStoreConfig('vm2mage/settings/debug_log') == 0) {
92
+ return false;
93
+ }
94
+
95
+ ini_set('display_errors', 1);
96
+ Mage::setIsDeveloperMode(true);
97
+ return true;
98
+ }
99
+
100
  /*
101
  * Recursive function to encode a value
102
  */
app/code/community/Yireo/Vm2Mage/Helper/Image.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -54,59 +54,54 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
54
  */
55
  public function addImages($product = null, $images = null)
56
  {
57
- //Mage::helper('vm2mage')->debug('Images', $images);
58
-
59
- // Check whether the images are already there
60
- $gallery_images = $product->getMediaGalleryImages();
61
- if(is_object($gallery_images) && $gallery_images->count() >= count($images)) {
62
- return $product;
63
- }
64
-
65
- // Loop through the images and create them
66
- if(is_array($images) && !empty($images)) {
67
- foreach($images as $image) {
 
 
 
 
 
 
68
 
69
- if(empty($image['label'])) $image['label'] = $product->getName();
70
- if(empty($image['file'])) $image['file'] = null;
71
- if(empty($image['md5sum'])) $image['md5sum'] = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- $result = self::addLocalImage($product, $image['file'], $image['label']);
74
- if($result != false) {
75
- $product = $result;
76
- } else {
77
- $result = self::addRemoteImage($product, $image['url'], $image['md5sum'], $image['type'], $image['label']);
78
  if($result != false) {
79
  $product = $result;
 
 
 
 
 
80
  }
81
  }
82
  }
83
  }
84
 
85
- // Set the full image and thumbnail
86
- $i = 0;
87
- $images = $product->getMediaGallery('images');
88
- foreach($images as $image) {
89
-
90
- $image_file = $image['file'];
91
- $image_label = $product->getName();
92
-
93
- if($i == 0) {
94
- $product->setImage($image_file);
95
- $product->setImageLabel($image_label);
96
- $product->setSmallImage($image_file);
97
- $product->setSmallImageLabel($image_label);
98
-
99
- } elseif($i == 1) {
100
- $product->setThumbnailLabel($image_label);
101
- $product->setThumbnail($image_file);
102
-
103
- } else {
104
- break;
105
- }
106
-
107
- $i++;
108
- }
109
-
110
  return $product;
111
  }
112
 
@@ -120,7 +115,7 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
120
  * @param string $label thumb_image|full_image|gallery
121
  * @return Mage_Catalog_Model_Product $product
122
  */
123
- public function addRemoteImage($product = null, $url = null, $md5sum = null, $type = null, $label = null)
124
  {
125
 
126
  // Try to create the import-directory it it does not exist
@@ -154,7 +149,7 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
154
  }
155
 
156
  // Add the image to the gallery
157
- $product = $product->addImageToMediaGallery($tmp_file, 'media_gallery', true, false);
158
 
159
  // Clean temporary file if needed
160
  if(file_exists($tmp_file)) {
@@ -174,8 +169,13 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
174
  * @param string $label thumb_image|full_image|gallery
175
  * @return Mage_Catalog_Model_Product $product
176
  */
177
- public function addLocalImage($product = null, $file = null, $label = null)
178
  {
 
 
 
 
 
179
  // Try to create the import-directory it it does not exist
180
  $base_dir = Mage::getBaseDir('media').DS.'import';
181
  if(is_dir($base_dir) == false) {
@@ -188,7 +188,9 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
188
  return false;
189
  }
190
 
191
- if(@is_readable($file) == false) {
 
 
192
  Mage::helper('vm2mage')->debug('ERROR: Image is not readable', $file);
193
  return false;
194
  }
@@ -203,7 +205,7 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
203
  }
204
 
205
  // Add the image to the gallery
206
- $product = $product->addImageToMediaGallery($tmp_file, 'media_gallery', true, false);
207
 
208
  // Clean temporary file if needed
209
  if(file_exists($tmp_file)) {
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
54
  */
55
  public function addImages($product = null, $images = null)
56
  {
57
+ // Option to renew images or not
58
+ $renewImages = (bool)Mage::getStoreConfig('vm2mage/settings/renew_images');
59
+
60
+ // Renew images
61
+ if($renewImages) {
62
+ Mage::helper('vm2mage')->debug('NOTICE: Removing existing images');
63
+
64
+ // Check whether the images are already there
65
+ $galleryImages = $product->getMediaGalleryImages();
66
+ if(is_object($galleryImages) && $galleryImages->count() >= count($images)) {
67
+ $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
68
+ $mediaGalleryAttribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, 'media_gallery');
69
+ foreach ($galleryImages as $galleryImage) {
70
+ $mediaGalleryAttribute->getBackend()->removeImage($product, $galleryImage->getFile());
71
+ }
72
+ $product->save();
73
+ }
74
 
75
+ // Loop through the images and create them
76
+ if(is_array($images) && !empty($images)) {
77
+ foreach($images as $image) {
78
+
79
+ if(empty($image['label'])) $image['label'] = $product->getName();
80
+ if(empty($image['file'])) $image['file'] = null;
81
+ if(empty($image['md5sum'])) $image['md5sum'] = null;
82
+
83
+ $imageTypes = array();
84
+ if($image['type'] == 'full_image') {
85
+ $imageTypes[] = 'image';
86
+ $imageTypes[] = 'small_image';
87
+ if(count($images) == 1) $imageTypes[] = 'thumbnail';
88
+ } elseif($image['type'] == 'thumb_image') {
89
+ $imageTypes[] = 'thumbnail';
90
+ }
91
 
92
+ $result = self::addLocalImage($product, $image['file'], $image['label'], $imageTypes);
 
 
 
 
93
  if($result != false) {
94
  $product = $result;
95
+ } else {
96
+ $result = self::addRemoteImage($product, $image['url'], $image['md5sum'], $image['type'], $image['label'], $imageTypes);
97
+ if($result != false) {
98
+ $product = $result;
99
+ }
100
  }
101
  }
102
  }
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  return $product;
106
  }
107
 
115
  * @param string $label thumb_image|full_image|gallery
116
  * @return Mage_Catalog_Model_Product $product
117
  */
118
+ public function addRemoteImage($product = null, $url = null, $md5sum = null, $type = null, $label = null, $types = array())
119
  {
120
 
121
  // Try to create the import-directory it it does not exist
149
  }
150
 
151
  // Add the image to the gallery
152
+ $product = $product->addImageToMediaGallery($tmp_file, $types, true, false);
153
 
154
  // Clean temporary file if needed
155
  if(file_exists($tmp_file)) {
169
  * @param string $label thumb_image|full_image|gallery
170
  * @return Mage_Catalog_Model_Product $product
171
  */
172
+ public function addLocalImage($product = null, $file = null, $label = null, $types = array())
173
  {
174
+ // Check if local-image-loading is enabled
175
+ if(Mage::getStoreConfig('vm2mage/settings/local_images') == 0) {
176
+ return false;
177
+ }
178
+
179
  // Try to create the import-directory it it does not exist
180
  $base_dir = Mage::getBaseDir('media').DS.'import';
181
  if(is_dir($base_dir) == false) {
188
  return false;
189
  }
190
 
191
+ $readable = false;
192
+ try { $readable = @is_readable($file); } catch(Exception $e) {}
193
+ if($readable == false) {
194
  Mage::helper('vm2mage')->debug('ERROR: Image is not readable', $file);
195
  return false;
196
  }
205
  }
206
 
207
  // Add the image to the gallery
208
+ $product = $product->addImageToMediaGallery($tmp_file, $types, true, false);
209
 
210
  // Clean temporary file if needed
211
  if(file_exists($tmp_file)) {
app/code/community/Yireo/Vm2Mage/Helper/Price.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/Helper/Product.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -20,7 +20,7 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
20
  * @param array $values
21
  * @return array
22
  */
23
- public function addChildrenToConfigurable($children = array(), $attribute_codes = array(), $product = null)
24
  {
25
  // Create the children first as Simple Products and them to usable arrays
26
  $childIds = array();
@@ -34,7 +34,7 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
34
  }
35
 
36
  // Insert the Simple Products that belong in this Configurable Product
37
- $loader = Mage::getResourceModel('catalog/product_type_configurable')->load($product);
38
  $loader->saveProducts($product, $childIds);
39
 
40
  // Gather the attribute-objects for use in this Configurable Product
@@ -42,9 +42,10 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
42
  $productData = array();
43
  $attributeIds = array();
44
  $i = 0;
45
- foreach($attribute_codes as $attribute_code) {
46
- $attribute = $product->getResource()->getAttribute($attribute_code);
47
- if($product->getTypeInstance()->canUseAttribute($attribute)) {
 
48
  if(!in_array($attribute->getAttributeId(), $attributeIds)) {
49
  $attributeIds[] = $attribute->getAttributeId();
50
  }
@@ -89,5 +90,64 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
89
  return array(0, $e->getMessage());
90
  }
91
  }
92
- }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
20
  * @param array $values
21
  * @return array
22
  */
23
+ public function addChildrenToConfigurable($children = array(), $attributeCodes = array(), $product = null)
24
  {
25
  // Create the children first as Simple Products and them to usable arrays
26
  $childIds = array();
34
  }
35
 
36
  // Insert the Simple Products that belong in this Configurable Product
37
+ $loader = Mage::getResourceModel('catalog/product_type_configurable')->load($product, null);
38
  $loader->saveProducts($product, $childIds);
39
 
40
  // Gather the attribute-objects for use in this Configurable Product
42
  $productData = array();
43
  $attributeIds = array();
44
  $i = 0;
45
+ foreach($attributeCodes as $attributeCode) {
46
+ $attributeCode = Mage::helper('vm2mage/attribute')->convertAttributeCode($attributeCode);
47
+ $attribute = $product->getResource()->getAttribute($attributeCode);
48
+ if(!empty($attribute) && $product->getTypeInstance()->canUseAttribute($attribute)) {
49
  if(!in_array($attribute->getAttributeId(), $attributeIds)) {
50
  $attributeIds[] = $attribute->getAttributeId();
51
  }
90
  return array(0, $e->getMessage());
91
  }
92
  }
 
93
 
94
+ /*
95
+ * Helper-method to add child-products to a grouped product
96
+ *
97
+ * @param array $values
98
+ * @return array
99
+ */
100
+ public function addChildrenToGrouped($children = array(), $product = null)
101
+ {
102
+ // Create the children first as Simple Products and them to usable arrays
103
+ $childIds = array();
104
+ foreach($children as $child) {
105
+ $childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
106
+ if(empty($childId)) {
107
+ Mage::getModel('vm2mage/product_api')->migrate($child);
108
+ $childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
109
+ }
110
+ $childIds[] = $childId;
111
+ }
112
+
113
+ // Insert the Simple Products that belong in this Configurable Product
114
+ foreach($childIds as $childId) {
115
+ $productsLinks = Mage::getModel('catalog/product_link_api');
116
+ $productsLinks->assign('grouped', $product->getId(), $childId);
117
+ }
118
+
119
+ // Try to safe this product to the database
120
+ try {
121
+ $product->save();
122
+ } catch(Exception $e) {
123
+ return array(0, $e->getMessage());
124
+ }
125
+ }
126
+
127
+ /*
128
+ * Helper-method to add a list of product-SKUs to a product as related products
129
+ *
130
+ * @param array $values
131
+ * @return array
132
+ */
133
+ public function addRelatedProducts($product, $children = array())
134
+ {
135
+ $relatedProductsData = array();
136
+ if(!empty($children)) {
137
+ $i = 0;
138
+ foreach($children as $child_sku) {
139
+ $relatedProductId = Mage::getModel('catalog/product')->getIdBySku($child_sku);
140
+ if($relatedProductId > 0) {
141
+ $relatedProductsData[$relatedProductId] = array('position' => $i);
142
+ $i++;
143
+ }
144
+ }
145
+ }
146
+
147
+ if(!empty($relatedProductsData)) {
148
+ $product->setRelatedLinkData($relatedProductsData);
149
+ }
150
+
151
+ return $product;
152
+ }
153
+ }
app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -23,33 +23,68 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
23
  if(!is_array($data) || empty($data['name'])) {
24
  return array(0, "Attribute is not an array");
25
  }
26
- // @todo: Option to enable debugging
27
- #Mage::helper('vm2mage')->debug('VirtueMart attribute', $data);
28
-
29
- // Quick filter for the attribute-name
30
- $data['name'] = strtolower($data['name']);
31
 
32
- // Flag on whether to save this attribute
33
- $do_save = false;
 
 
 
 
 
 
 
 
 
34
 
35
  // Get an attribute-object
36
  $product = Mage::getModel('catalog/product');
37
- $attribute = Mage::getModel('catalog/entity_attribute');
38
  $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
39
  ->setEntityTypeFilter($product->getResource()->getTypeId())
40
- ->addFieldToFilter('attribute_code', $data['name'])
41
  ->load(false);
42
- $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  unset($product,$attributes);
44
 
45
  // Create a new attribute
46
  if(!$attribute->getId() > 0) {
47
- $do_save = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  $attribute
49
- ->setAttributeCode($data['name'])
50
  ->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId())
51
  ->setIsComparable(0)
52
- ->setIsConfigurable(1)
53
  ->setIsFilterable(0)
54
  ->setIsFilterableInSearch(0)
55
  ->setIsGlobal(1)
@@ -60,11 +95,13 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
60
  ->setIsUsedForPriceRules(0)
61
  ->setIsVisibleInAdvancedSearch(0)
62
  ->setIsVisibleOnFront(0)
63
- ->setDefaultValueYesno(0)
64
  ->setUsedInProductListing(0)
65
- ->setFrontendInput('select')
66
  ->setFrontendLabel(array($data['label'], $data['label']))
67
- ->setBackendType($attribute->getBackendTypeByInput('select'))
 
 
68
  ;
69
 
70
  // Add it to the default attribute-set and the first group
@@ -80,8 +117,8 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
80
  }
81
 
82
  // Add other data
83
- $attribute->setData('backend_model', 'eav/entity_attribute_backend_array');
84
- $attribute->setData('apply_to', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
85
  }
86
 
87
  // Get the existing attribute-options
@@ -91,29 +128,36 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
91
  }
92
 
93
  // Strip these existing attribute-options from the incoming options
94
- foreach($data['values'] as $index => $value) {
95
- if(in_array($value, $existing_options)) unset($data['values'][$index]);
 
 
 
96
  }
97
 
98
  // Set the remaining attribute-options
99
  if(!empty($data['values'])) {
100
- $do_save = true;
101
  $options = Mage::helper('vm2mage/attribute')->valueToOptions($data['values']);
102
  $attribute->setOption($options);
103
  }
104
 
105
  // Do not save anything if this is needed
106
- if($do_save == false) {
107
- return array(1, "No changes in '".$data['name']."'");
108
  }
109
 
110
  // Save the attribute
111
  try {
112
  $attribute->save();
113
  } catch(Exception $e) {
114
- return array(0, $e->getMessage());
115
  }
116
 
117
- return array(1, "Successfully saved attribute '".$data['name']."'");
 
 
 
 
118
  }
119
  }
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
23
  if(!is_array($data) || empty($data['name'])) {
24
  return array(0, "Attribute is not an array");
25
  }
 
 
 
 
 
26
 
27
+ // Debugging
28
+ Mage::helper('vm2mage')->debug('VirtueMart attribute', $data);
29
+
30
+ // Flags
31
+ $isNew = false;
32
+ $doSave = false;
33
+ if(Mage::getStoreConfig('vm2mage/settings/delete_attributes') == 1) $doSave = true;
34
+
35
+ // Convert the attribute-code
36
+ $attributeCode = $data['name'];
37
+ $attributeCode = Mage::helper('vm2mage/attribute')->convertAttributeCode($attributeCode);
38
 
39
  // Get an attribute-object
40
  $product = Mage::getModel('catalog/product');
 
41
  $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
42
  ->setEntityTypeFilter($product->getResource()->getTypeId())
43
+ ->addFieldToFilter('attribute_code', $attributeCode)
44
  ->load(false);
45
+ $attribute = $attributes->getFirstItem();
46
+ $attribute->setEntity($product->getResource());
47
+
48
+ // Delete the attribute if it already exists
49
+ if($attribute->getId() > 0 && Mage::getStoreConfig('vm2mage/settings/delete_attributes') == 1) {
50
+ $model = Mage::getModel('catalog/resource_eav_attribute');
51
+ $model->load($attribute->getId());
52
+ try {
53
+ $model->delete();
54
+ } catch(Exception $e) {}
55
+
56
+ $attribute = $attributes->getFirstItem();
57
+ $attribute->setEntity($product->getResource());
58
+ }
59
+
60
+ // Unset the variables to make sure they don't interfer
61
  unset($product,$attributes);
62
 
63
  // Create a new attribute
64
  if(!$attribute->getId() > 0) {
65
+
66
+ $doSave = true;
67
+ $isNew = true;
68
+
69
+ if(empty($data['values'])) {
70
+ $frontendInput = 'boolean';
71
+ $defaultValueYesNo = 1;
72
+ $backendModel = 'catalog/product_attribute_backend_boolean';
73
+ $sourceModel = 'eav/entity_attribute_source_boolean';
74
+ } else {
75
+ $frontendInput = 'select';
76
+ $defaultValueYesNo = 0;
77
+ $backendModel = 'eav/entity_attribute_backend_array';
78
+ $sourceModel = 'eav/entity_attribute_source_table';
79
+ }
80
+
81
+ $configurable = (!empty($data['configurable']) && $data['configurable'] == 1) ? 1 : 0;
82
+
83
  $attribute
84
+ ->setAttributeCode($attributeCode)
85
  ->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId())
86
  ->setIsComparable(0)
87
+ ->setIsConfigurable($configurable)
88
  ->setIsFilterable(0)
89
  ->setIsFilterableInSearch(0)
90
  ->setIsGlobal(1)
95
  ->setIsUsedForPriceRules(0)
96
  ->setIsVisibleInAdvancedSearch(0)
97
  ->setIsVisibleOnFront(0)
98
+ ->setDefaultValueYesno($defaultValueYesNo)
99
  ->setUsedInProductListing(0)
100
+ ->setFrontendInput($frontendInput)
101
  ->setFrontendLabel(array($data['label'], $data['label']))
102
+ ->setBackendType($attribute->getBackendTypeByInput($frontendInput))
103
+ ->setBackendModel($backendModel)
104
+ ->setSourceModel($sourceModel)
105
  ;
106
 
107
  // Add it to the default attribute-set and the first group
117
  }
118
 
119
  // Add other data
120
+ $attribute->setData('apply_to', 0);
121
+ //$attribute->setData('apply_to', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
122
  }
123
 
124
  // Get the existing attribute-options
128
  }
129
 
130
  // Strip these existing attribute-options from the incoming options
131
+ if(!empty($data['values'])) {
132
+ foreach($data['values'] as $index => $value) {
133
+ if(empty($value)) continue;
134
+ if(in_array($value, $existing_options)) unset($data['values'][$index]);
135
+ }
136
  }
137
 
138
  // Set the remaining attribute-options
139
  if(!empty($data['values'])) {
140
+ $doSave = true;
141
  $options = Mage::helper('vm2mage/attribute')->valueToOptions($data['values']);
142
  $attribute->setOption($options);
143
  }
144
 
145
  // Do not save anything if this is needed
146
+ if($doSave == false) {
147
+ return array(1, "No changes in '".$attributeCode."'");
148
  }
149
 
150
  // Save the attribute
151
  try {
152
  $attribute->save();
153
  } catch(Exception $e) {
154
+ return array(0, '['.$attributeCode.'] '.$e->getMessage());
155
  }
156
 
157
+ if($isNew) {
158
+ return array(1, "Created attribute '".$attributeCode."'");
159
+ } else {
160
+ return array(1, "Updated attribute '".$attributeCode."'");
161
+ }
162
  }
163
  }
app/code/community/Yireo/Vm2Mage/Model/Category/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -26,13 +26,13 @@ class Yireo_Vm2Mage_Model_Category_Api extends Mage_Catalog_Model_Category_Api
26
 
27
  // Decode all values
28
  $data = Mage::helper('vm2mage')->decode($data);
29
- #Mage::helper('vm2mage')->debug('VirtueMart category', $data);
30
 
31
  // Get a clean category-object
32
  $category = Mage::getModel('catalog/category');
33
 
34
  // Try to load the category
35
- $categoryId = Mage::helper('vm2mage/category')->getMageId($data['id']);
36
  if(!empty($categoryId)) {
37
  $category->load($categoryId);
38
  }
@@ -42,7 +42,7 @@ class Yireo_Vm2Mage_Model_Category_Api extends Mage_Catalog_Model_Category_Api
42
 
43
  // Get the parent by taking it from VirtueMart
44
  if(isset($data['parent_id']) && $data['parent_id'] > 0) {
45
- $parentId = Mage::helper('vm2mage/category')->getMageId($data['parent_id']);
46
 
47
  // Do not migrate this category (yet) if its parent does not exist yet
48
  if(!$parentId > 0) {
@@ -99,19 +99,23 @@ class Yireo_Vm2Mage_Model_Category_Api extends Mage_Catalog_Model_Category_Api
99
  return array(0, $e->getMessage());
100
  }
101
 
102
- // Move this
103
- if($category->getParentId() != $parentId) {
104
- $category->getResource()->move($category->getId(), $parentId);
 
 
 
 
105
  }
106
 
107
- // Safe this category-relation within Vm2Mage
108
- Mage::helper('vm2mage/category')->saveRelation($data['id'], $category->getId());
109
 
110
  // Return true by default
111
  if($isNew) {
112
- return array(1, "Created new category ".$category->getName());
113
  } else {
114
- return array(1, "Updated category ".$category->getName());
115
  }
116
  }
117
 
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
26
 
27
  // Decode all values
28
  $data = Mage::helper('vm2mage')->decode($data);
29
+ Mage::helper('vm2mage')->debug('VirtueMart category', $data);
30
 
31
  // Get a clean category-object
32
  $category = Mage::getModel('catalog/category');
33
 
34
  // Try to load the category
35
+ $categoryId = Mage::helper('vm2mage/category')->getMageId($data['id'], $data['migration_code']);
36
  if(!empty($categoryId)) {
37
  $category->load($categoryId);
38
  }
42
 
43
  // Get the parent by taking it from VirtueMart
44
  if(isset($data['parent_id']) && $data['parent_id'] > 0) {
45
+ $parentId = Mage::helper('vm2mage/category')->getMageId($data['parent_id'], $data['migration_code']);
46
 
47
  // Do not migrate this category (yet) if its parent does not exist yet
48
  if(!$parentId > 0) {
99
  return array(0, $e->getMessage());
100
  }
101
 
102
+ // Move this categort
103
+ if(!in_array($parentId, array(0, $category->getParentId(), $category->getId()))) {
104
+ try {
105
+ $category->move($category->getId(), $parentId);
106
+ } catch(Exception $e) {
107
+ // Do nothing
108
+ }
109
  }
110
 
111
+ // Save this category-relation within Vm2Mage
112
+ Mage::helper('vm2mage/category')->saveRelation($data['id'], $category->getId(), $data['migration_code']);
113
 
114
  // Return true by default
115
  if($isNew) {
116
+ return array(1, "Created new category ".$category->getName(), $data['id']);
117
  } else {
118
+ return array(1, "Updated category ".$category->getName(), $data['id']);
119
  }
120
  }
121
 
app/code/community/Yireo/Vm2Mage/Model/Observer.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/Model/Order/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/Model/Product/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -21,17 +21,25 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
21
  {
22
  // Check for empty data
23
  if(!is_array($data)) {
24
- #Mage::helper('vm2mage')->debug('VirtueMart product', $data);
25
  return array(0, "Data is not an array");
26
  }
27
 
28
  // Decode all values
29
  $data = Mage::helper('vm2mage')->decode($data);
30
- // @todo: Option to enable debugging
31
- #Mage::helper('vm2mage')->debug('VirtueMart product', $data);
32
 
33
- // @todo: Optionally lock the indexer
34
- //Mage::getSingleton('index/indexer')->lockIndexer();
 
 
 
 
 
 
 
 
 
35
 
36
  // Get a clean product-object
37
  $product = Mage::getModel('catalog/product');
@@ -54,22 +62,19 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
54
  ->setId(null)
55
  ->setCreatedAt(null)
56
  ->setUpdatedAt(null)
57
- ->setStoreId($storeId)
58
  ->setAttributeSetId($product->getDefaultAttributeSetId())
59
  ;
60
 
61
- if($data['has_children'] > 0) {
62
- $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
63
- } else {
64
- $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
65
- }
66
  }
67
 
68
  // Make sure the status is set
69
  if(!isset($data['status'])) {
70
- $data['status'] = 1;
 
 
71
  }
72
- $data['status'] = 1;
73
 
74
  // Make sure there is a short-description
75
  if(empty($data['short_description'])) {
@@ -78,7 +83,6 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
78
 
79
  // Set common attributes
80
  $product->setData($product->getData())
81
- ->setStoreId($storeId)
82
  ->setWebsiteIds(array(Mage::getModel('core/store')->load($storeId)->getWebsiteId()))
83
  ->setSku($data['sku'])
84
  ->setName($data['name'])
@@ -120,20 +124,19 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
120
  // Set the custom attributes
121
  if(isset($data['attributes'])) {
122
  foreach($data['attributes'] as $name => $value) {
123
- #Mage::helper('vm2mage')->debug('Product attribute', $name);
124
  $product = Mage::helper('vm2mage/attribute')->addAttributeToProduct($product, $name, $value);
125
  }
126
  }
127
 
128
  // Set the price
129
- // @todo: Include support for tier pricing
130
  if(isset($data['price']['product_price'])) {
131
- $product->setPrice($data['price']['product_price']);
132
  }
133
 
134
  // Set the special price
135
  if(isset($data['special_price']['price'])) {
136
- $product->setSpecialPrice($data['special_price']['price']);
137
  }
138
 
139
  // Set the special price from-date
@@ -147,28 +150,39 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
147
  }
148
 
149
  // Handle the stock
150
- if(isset($data['in_stock']) && $data['in_stock'] > 0) {
 
151
  $stockData = $product->getStockData();
152
- #Mage::helper('vm2mage')->debug('VirtueMart product stock-data', $stockData);
153
  $stockData['qty'] = $data['in_stock'];
154
  $stockData['is_in_stock'] = 1;
155
  $stockData['manage_stock'] = 1;
156
  $stockData['use_config_manage_stock'] = 0;
157
  $product->setStockData($stockData);
 
 
 
 
158
  }
159
 
160
  // Convert the category-IDs
161
  if(!empty($data['category_ids'])) {
162
  $category_ids = array();
163
  foreach($data['category_ids'] as $vm_id) {
164
- $id = Mage::helper('vm2mage/category')->getMageId($vm_id);
 
 
 
 
165
  if($id > 0) $category_ids[] = $id;
166
  }
167
-
168
- if(!empty($category_ids)) {
169
- $product->setCategoryIds($category_ids);
170
- }
171
  }
 
 
 
 
 
 
172
 
173
  // Set the mass-update flags to prevent reindexing for now
174
  $product->setIsMassupdate(true);
@@ -183,18 +197,36 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
183
  }
184
  }
185
 
 
 
 
 
 
 
 
 
 
186
  // Try to save this product to the database
187
  try {
188
  $request = Mage::app()->getFrontController()->getRequest();
189
  Mage::dispatchEvent('catalog_product_prepare_save', array('product' => $product, 'request' => $request));
190
  $product->save();
191
  } catch(Exception $e) {
192
- return array(0, $e->getMessage());
193
  }
194
 
195
  // Configure this product as configurable product
196
  if($data['has_children'] > 0) {
197
- $rs = Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], $data['attributes_sku'], $product);
 
 
 
 
 
 
 
 
 
198
  if(!empty($rs)) {
199
  return $rs;
200
  }
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
21
  {
22
  // Check for empty data
23
  if(!is_array($data)) {
24
+ //Mage::helper('vm2mage')->debug('VirtueMart product', $data);
25
  return array(0, "Data is not an array");
26
  }
27
 
28
  // Decode all values
29
  $data = Mage::helper('vm2mage')->decode($data);
30
+ //Mage::helper('vm2mage')->debug('VirtueMart product', $data);
 
31
 
32
+ // Determine the product-type
33
+ if($data['has_children'] > 0) {
34
+ // @todo: Provide a switch
35
+ $typeId = Mage_Catalog_Model_Product_Type::TYPE_GROUPED;
36
+ //$typeId = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE;
37
+ } else {
38
+ $typeId = Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
39
+ }
40
+
41
+ // Optionally lock the indexer
42
+ Mage::getSingleton('index/indexer')->lockIndexer();
43
 
44
  // Get a clean product-object
45
  $product = Mage::getModel('catalog/product');
62
  ->setId(null)
63
  ->setCreatedAt(null)
64
  ->setUpdatedAt(null)
 
65
  ->setAttributeSetId($product->getDefaultAttributeSetId())
66
  ;
67
 
68
+ // Set the proper type-ID
69
+ $product->setTypeId($typeId);
 
 
 
70
  }
71
 
72
  // Make sure the status is set
73
  if(!isset($data['status'])) {
74
+ $data['status'] = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
75
+ } elseif($data['status'] == 0) {
76
+ $data['status'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
77
  }
 
78
 
79
  // Make sure there is a short-description
80
  if(empty($data['short_description'])) {
83
 
84
  // Set common attributes
85
  $product->setData($product->getData())
 
86
  ->setWebsiteIds(array(Mage::getModel('core/store')->load($storeId)->getWebsiteId()))
87
  ->setSku($data['sku'])
88
  ->setName($data['name'])
124
  // Set the custom attributes
125
  if(isset($data['attributes'])) {
126
  foreach($data['attributes'] as $name => $value) {
127
+ //Mage::helper('vm2mage')->debug('Product attribute', $name);
128
  $product = Mage::helper('vm2mage/attribute')->addAttributeToProduct($product, $name, $value);
129
  }
130
  }
131
 
132
  // Set the price
 
133
  if(isset($data['price']['product_price'])) {
134
+ $product->setPrice((float)$data['price']['product_price']);
135
  }
136
 
137
  // Set the special price
138
  if(isset($data['special_price']['price'])) {
139
+ $product->setSpecialPrice((float)$data['special_price']['price']);
140
  }
141
 
142
  // Set the special price from-date
150
  }
151
 
152
  // Handle the stock
153
+ if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) $data['in_stock'] = null;
154
+ if(!empty($data['in_stock']) && $data['in_stock'] > 0) {
155
  $stockData = $product->getStockData();
156
+ //Mage::helper('vm2mage')->debug('VirtueMart product stock-data', $stockData);
157
  $stockData['qty'] = $data['in_stock'];
158
  $stockData['is_in_stock'] = 1;
159
  $stockData['manage_stock'] = 1;
160
  $stockData['use_config_manage_stock'] = 0;
161
  $product->setStockData($stockData);
162
+ } else {
163
+ $stockData = $product->getStockData();
164
+ $stockData['manage_stock'] = 0;
165
+ $product->setStockData($stockData);
166
  }
167
 
168
  // Convert the category-IDs
169
  if(!empty($data['category_ids'])) {
170
  $category_ids = array();
171
  foreach($data['category_ids'] as $vm_id) {
172
+ if(isset($data['migration_code'])) {
173
+ $id = Mage::helper('vm2mage/category')->getMageId($vm_id, $data['migration_code']);
174
+ } else {
175
+ $id = Mage::helper('vm2mage/category')->getMageId($vm_id);
176
+ }
177
  if($id > 0) $category_ids[] = $id;
178
  }
 
 
 
 
179
  }
180
+
181
+ if(empty($category_ids)) {
182
+ $category_ids = array(1);
183
+ }
184
+
185
+ $product->setCategoryIds($category_ids);
186
 
187
  // Set the mass-update flags to prevent reindexing for now
188
  $product->setIsMassupdate(true);
197
  }
198
  }
199
 
200
+ // Add the related products
201
+ if(!empty($data['related_products'])) {
202
+ try {
203
+ $product = Mage::helper('vm2mage/product')->addRelatedProducts($product, $data['related_products']);
204
+ } catch(Exception $e) {
205
+ return array(0, $e->getMessage());
206
+ }
207
+ }
208
+
209
  // Try to save this product to the database
210
  try {
211
  $request = Mage::app()->getFrontController()->getRequest();
212
  Mage::dispatchEvent('catalog_product_prepare_save', array('product' => $product, 'request' => $request));
213
  $product->save();
214
  } catch(Exception $e) {
215
+ return array(0, '['.$sku.'] '.$e->getMessage());
216
  }
217
 
218
  // Configure this product as configurable product
219
  if($data['has_children'] > 0) {
220
+ if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
221
+ $rs = Mage::helper('vm2mage/product')->addChildrenToGrouped($data['children'], $product);
222
+ } else {
223
+ if(isset($data['attributes_sku']) && is_array($data['attributes_sku'])) {
224
+ $rs = Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], $data['attributes_sku'], $product);
225
+ } else {
226
+ $rs = Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], array(), $product);
227
+ }
228
+ }
229
+
230
  if(!empty($rs)) {
231
  return $rs;
232
  }
app/code/community/Yireo/Vm2Mage/Model/Rewrite/Category/Attribute/Backend/Image.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Yireo_Vm2Mage_Model_Rewrite_Category_Attribute_Backend_Image extends Mage_Catalog_Model_Category_Attribute_Backend_Image
3
+ {
4
+ public function afterSave($object)
5
+ {
6
+ $value = $object->getData($this->getAttribute()->getName());
7
+
8
+ if (is_array($value) && !empty($value['delete'])) {
9
+ $object->setData($this->getAttribute()->getName(), '');
10
+ $this->getAttribute()->getEntity()
11
+ ->saveAttribute($object, $this->getAttribute()->getName());
12
+ return;
13
+ }
14
+
15
+ if (!isset($_FILES) || count($_FILES) == 0) {
16
+ return;
17
+ }
18
+
19
+ $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
20
+
21
+ try {
22
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
23
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
24
+ $uploader->setAllowRenameFiles(true);
25
+ $result = $uploader->save($path);
26
+
27
+ $object->setData($this->getAttribute()->getName(), $result['file']);
28
+ $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
29
+ } catch (Exception $e) {
30
+ if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
31
+ Mage::logException($e);
32
+ }
33
+ /** @TODO ??? */
34
+ return;
35
+ }
36
+ }
37
+ }
app/code/community/Yireo/Vm2Mage/Model/User/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
@@ -105,7 +105,7 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
105
  // Save the address
106
  if(isset($data['addresses']) && !empty($data['addresses'])) {
107
  foreach($data['addresses'] as $address) {
108
- $rt = $this->saveAddress($customer, $address);
109
  }
110
  } else {
111
  $rt = $this->saveAddress($customer, $data);
@@ -139,7 +139,7 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
139
  /**
140
  * Save the customer address
141
  */
142
- private function saveAddress($customer, $data)
143
  {
144
  // Load both addressses
145
  $shippingAddress = $customer->getPrimaryShippingAddress();
@@ -177,10 +177,14 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
177
  return false;
178
  }
179
 
180
- // Load the country and region
181
  $country = null;
182
- $region = null;
183
  if(!empty($data['country'])) $country = Mage::getModel('directory/country')->loadByCode($data['country']);
 
 
 
 
184
  if(!empty($data['region'])) $region = Mage::getModel('directory/region')->loadByCode($data['state'], $country->getId());
185
 
186
  // Set basic values
@@ -212,9 +216,15 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
212
  }
213
  }
214
 
215
- // Load the country and region
216
- if(!empty($country)) $address->setCountryId($country->getId());
217
- if(!empty($region)) $address->setRegionId($region->getId());
 
 
 
 
 
 
218
 
219
  // Set the customer if needed
220
  if(!$address->getCustomerId() > 0) $address->setCustomerId($customer->getId());
@@ -255,30 +265,51 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
255
  if(empty($productId) || $productId == 0) {
256
  return null;
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  try {
260
  $nickname = $customer->getFirstname();
261
  if(empty($nickname)) $nickname = '-';
 
262
 
263
  $review = Mage::getModel('review/review');
264
- $review->setEntityId(Mage_Review_Model_Review::ENTITY_PRODUCT);
265
- $review->setEntityPkValue($productId);
266
- $review->setCustomerId($customer->getId());
267
- $review->setStoreId($customer->getStoreId());
268
- $review->setStores(array($customer->getStoreId()));
 
 
 
 
 
 
269
  $review->setTitle('-');
270
  $review->setNickname($nickname);
271
  $review->setDetail($data['comment']);
272
- // drop $data['user_rating']
273
 
274
  $review->setCreatedAt(date('Y-m-d H:i:s', $data['time']));
275
  if(strtolower($data['published']) == 'y') {
276
- $review->setStatusId(1);
277
  } else {
278
- $review->setStatusId(2);
279
  }
280
 
281
  $rt = $review->save();
 
282
 
283
  } catch(Exception $e) {
284
  Mage::helper('vm2mage')->debug('Exception', $e->getMessage());
@@ -313,6 +344,7 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
313
  // Load the existing record
314
  $model = Mage::getModel('vmorder/order')->load($order['order_id'], 'order_id');
315
  $order_currency = (!empty($order['order_currency'])) ? $order['order_currency'] : $default_currency;
 
316
 
317
  // Set all important values
318
  $model->setCustomerId($customer_id);
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
105
  // Save the address
106
  if(isset($data['addresses']) && !empty($data['addresses'])) {
107
  foreach($data['addresses'] as $address) {
108
+ $rt = $this->saveAddress($customer, $address, $data);
109
  }
110
  } else {
111
  $rt = $this->saveAddress($customer, $data);
139
  /**
140
  * Save the customer address
141
  */
142
+ private function saveAddress($customer, $data, $customerData)
143
  {
144
  // Load both addressses
145
  $shippingAddress = $customer->getPrimaryShippingAddress();
177
  return false;
178
  }
179
 
180
+ // Load the country
181
  $country = null;
182
+ if(empty($data['country']) && !empty($customerData['country'])) $data['country'] = $customerData['country'];
183
  if(!empty($data['country'])) $country = Mage::getModel('directory/country')->loadByCode($data['country']);
184
+
185
+ // Load the region
186
+ $region = null;
187
+ if(empty($data['region']) && !empty($customerData['region'])) $data['region'] = $customerData['region'];
188
  if(!empty($data['region'])) $region = Mage::getModel('directory/region')->loadByCode($data['state'], $country->getId());
189
 
190
  // Set basic values
216
  }
217
  }
218
 
219
+ // Set the country
220
+ if(!empty($country)) {
221
+ $address->setCountryId($country->getId());
222
+ }
223
+
224
+ // Set the region
225
+ if(!empty($region)) {
226
+ $address->setRegionId($region->getId());
227
+ }
228
 
229
  // Set the customer if needed
230
  if(!$address->getCustomerId() > 0) $address->setCustomerId($customer->getId());
265
  if(empty($productId) || $productId == 0) {
266
  return null;
267
  }
268
+
269
+ // Detect if this review is already present
270
+ $collection = Mage::getModel('review/review')->getCollection()
271
+ ->addFieldToFilter('entity_id', Mage_Review_Model_Review::ENTITY_PRODUCT)
272
+ ->addFieldToFilter('entity_pk_value', $productId)
273
+ ->addFieldToFilter('customer_id', $customer->getId())
274
+ ;
275
+ if($collection->count() > 0) {
276
+ $review = $collection->getFirstItem();
277
+ $reviewId = $review->getId();
278
+ } else {
279
+ $reviewId = null;
280
+ }
281
 
282
  try {
283
  $nickname = $customer->getFirstname();
284
  if(empty($nickname)) $nickname = '-';
285
+ if(empty($data['user_rating'])) $data['user_rating'] = 4;
286
 
287
  $review = Mage::getModel('review/review');
288
+ if($reviewId > 0) {
289
+ $review->load($reviewId);
290
+ } else {
291
+ $review->setEntityId(Mage_Review_Model_Review::ENTITY_PRODUCT);
292
+ $review->setEntityPkValue($productId);
293
+ $review->setCustomerId($customer->getId());
294
+ $storeId = Mage::app()->getStore($customer->getStoreId())->getId();
295
+ $review->setStoreId($storeId);
296
+ $review->setStores(array($storeId));
297
+ }
298
+
299
  $review->setTitle('-');
300
  $review->setNickname($nickname);
301
  $review->setDetail($data['comment']);
302
+ $review->setRatingSummary($data['user_rating']);
303
 
304
  $review->setCreatedAt(date('Y-m-d H:i:s', $data['time']));
305
  if(strtolower($data['published']) == 'y') {
306
+ $review->setStatusId(Mage_Review_Model_Review::STATUS_APPROVED);
307
  } else {
308
+ $review->setStatusId(Mage_Review_Model_Review::STATUS_PENDING);
309
  }
310
 
311
  $rt = $review->save();
312
+ $review->aggregate();
313
 
314
  } catch(Exception $e) {
315
  Mage::helper('vm2mage')->debug('Exception', $e->getMessage());
344
  // Load the existing record
345
  $model = Mage::getModel('vmorder/order')->load($order['order_id'], 'order_id');
346
  $order_currency = (!empty($order['order_currency'])) ? $order['order_currency'] : $default_currency;
347
+ $order_status_name = (!empty($order['order_status_name'])) ? $order['order_status_name'] : $order['order_status'];
348
 
349
  // Set all important values
350
  $model->setCustomerId($customer_id);
app/code/community/Yireo/Vm2Mage/Model/Widget/Api.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/controllers/IndexController.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/etc/api.xml CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @author Yireo
7
  * @package Vm2Mage
8
- * @copyright Copyright 2011
9
  * @license Open Source License
10
  * @link http://www.yireo.com
11
  */
5
  *
6
  * @author Yireo
7
  * @package Vm2Mage
8
+ * @copyright Copyright 2013
9
  * @license Open Source License
10
  * @link http://www.yireo.com
11
  */
app/code/community/Yireo/Vm2Mage/etc/config.xml CHANGED
@@ -5,7 +5,7 @@
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,7 +14,7 @@
14
 
15
  <modules>
16
  <Yireo_Vm2Mage>
17
- <version>0.10.0</version>
18
  </Yireo_Vm2Mage>
19
  </modules>
20
 
@@ -35,6 +35,11 @@
35
  <vm2mage>
36
  <class>Yireo_Vm2Mage_Model</class>
37
  </vm2mage>
 
 
 
 
 
38
  </models>
39
 
40
  <resources>
@@ -129,4 +134,14 @@
129
  </routers>
130
  </admin>
131
 
 
 
 
 
 
 
 
 
 
 
132
  </config>
5
  *
6
  * @author Yireo
7
  * @package Vm2Mage
8
+ * @copyright Copyright 2013
9
  * @license Yireo EULA (www.yireo.com)
10
  * @link http://www.yireo.com
11
  */
14
 
15
  <modules>
16
  <Yireo_Vm2Mage>
17
+ <version>0.10.5</version>
18
  </Yireo_Vm2Mage>
19
  </modules>
20
 
35
  <vm2mage>
36
  <class>Yireo_Vm2Mage_Model</class>
37
  </vm2mage>
38
+ <catalog>
39
+ <rewrite>
40
+ <category_attribute_backend_image>Yireo_Vm2Mage_Model_Rewrite_Category_Attribute_Backend_Image</category_attribute_backend_image>
41
+ </rewrite>
42
+ </catalog>
43
  </models>
44
 
45
  <resources>
134
  </routers>
135
  </admin>
136
 
137
+ <default>
138
+ <vm2mage>
139
+ <settings>
140
+ <debug_log>0</debug_log>
141
+ <local_images>1</local_images>
142
+ <renew_images>1</renew_images>
143
+ <delete_attributes>0</delete_attributes>
144
+ </settings>
145
+ </vm2mage>
146
+ </default>
147
  </config>
app/code/community/Yireo/Vm2Mage/etc/system.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Vm2Mage
5
+ *
6
+ * @author Yireo
7
+ * @package Vm2Mage
8
+ * @copyright Copyright 2013
9
+ * @license Yireo EULA (www.yireo.com)
10
+ * @link http://www.yireo.com
11
+ */
12
+ -->
13
+ <config>
14
+ <sections>
15
+ <vm2mage translate="label" module="vm2mage">
16
+ <label>Vm2Mage</label>
17
+ <tab>service</tab>
18
+ <frontend_type>text</frontend_type>
19
+ <sort_order>342</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>1</show_in_store>
23
+ <groups>
24
+ <settings translate="label">
25
+ <label>System Options</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>2</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <debug_log translate="label">
33
+ <label>Debug Log</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>40</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <comment>Log debugging to MAGENTO/var/log/vm2mage.log</comment>
41
+ </debug_log>
42
+ <local_images translate="label">
43
+ <label>Local Images</label>
44
+ <frontend_type>select</frontend_type>
45
+ <source_model>adminhtml/system_config_source_yesno</source_model>
46
+ <sort_order>40</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ <comment>Try to copy images from local filesystem</comment>
51
+ </local_images>
52
+ <renew_images translate="label">
53
+ <label>Renew Images</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>40</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <comment>Delete old images and re-import new</comment>
61
+ </renew_images>
62
+ <delete_attributes translate="label">
63
+ <label>Delete Existing Attributes</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <sort_order>40</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <comment>Delete attributes if they already exist</comment>
71
+ </delete_attributes>
72
+ </fields>
73
+ </settings>
74
+ </groups>
75
+ </vm2mage>
76
+ </sections>
77
+ </config>
78
+
app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.10.3.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Vm2Mage for Magento
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+
12
+ $installer = $this;
13
+ $installer->startSetup();
14
+ $installer->run("
15
+ CREATE TABLE IF NOT EXISTS {$this->getTable('vm2mage_categories')} (
16
+ `vm_id` int(11) NOT NULL,
17
+ `mage_id` int(11) NOT NULL,
18
+ `migration_code` varchar(32) NOT NULL,
19
+ UNIQUE KEY `vm_id` (`vm_id`,`mage_id`, `migration_code`)
20
+ ) ENGINE=MyISAM;
21
+
22
+ ");
23
+ $installer->endSetup();
app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.5.4.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
- * @copyright Copyright 2011
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
4
  *
5
  * @author Yireo
6
  * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
  * @license Open Source License
9
  * @link http://www.yireo.com
10
  */
app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-upgrade-0.10.2-0.10.3.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Vm2Mage for Magento
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2013
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+
12
+ $installer = $this;
13
+ $installer->startSetup();
14
+ $installer->run("
15
+ ALTER TABLE {$this->getTable('vm2mage_categories')} ADD `migration_code` VARCHAR(32) NOT NULL AFTER `mage_id`;
16
+ ");
17
+ $installer->endSetup();
package.xml CHANGED
@@ -1,18 +1,2 @@
1
  <?xml version="1.0"?>
2
- <package>
3
- <name>Yireo_Vm2Mage</name>
4
- <version>0.10.0</version>
5
- <stability>stable</stability>
6
- <license>Open Source License</license>
7
- <channel>community</channel>
8
- <extends/>
9
- <summary>Migrates data from VirtueMart to Magento</summary>
10
- <description>Migrates data from VirtueMart to Magento</description>
11
- <notes>Migrates data from VirtueMart to Magento</notes>
12
- <authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors>
13
- <date>2013-02-26</date>
14
- <time>09:15:07</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Yireo_Vm2Mage.xml" hash="bee76713ff8df9db330a8385b2465041"/></dir></target><target name="magecommunity"><dir name="Yireo"><dir name="Vm2Mage"><dir name="Block"><file name="Check.php" hash="dae596a80acf62fd798cafec13a05584"/></dir><dir name="Helper"><file name="Attribute.php" hash="d73a26b0540348e8ad35f1e6a5789c87"/><file name="Category.php" hash="7d8311ec4cc146ef7ac9fa477cad05bc"/><file name="Data.php" hash="7184457a80bb2a974753d6bba7e045b9"/><file name="Image.php" hash="7374dddacd4ac0c6b71a34ad6904e243"/><file name="Price.php" hash="c21f7e2106c2f818fcc363349e727b9b"/><file name="Product.php" hash="8b1804224432971d11d73ce993fd49d3"/><file name="Product.php.old" hash="be8e09d7fd14e1f054dd540c26da6542"/></dir><dir name="Model"><dir name="Attribute"><file name="Api.php" hash="5774987d0db27eb1c587e7ed814afc68"/></dir><dir name="Category"><file name="Api.php" hash="0cd640c547cc6b141320f98932948105"/></dir><file name="Observer.php" hash="cdee87eb6b9b6904f00b1440b2517ba3"/><dir name="Order"><file name="Api.php" hash="6031c65939565544cec8553a6ce6f6a0"/></dir><dir name="Product"><file name="Api.php" hash="615e10c79dfa333680bca5e3110c50f9"/></dir><dir name="User"><file name="Api.php" hash="bff5f2b63aa610533bf3acc711a2368c"/></dir><dir name="Widget"><file name="Api.php" hash="e1e93c3125e6f45a62c20faf2543df65"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="37eacaa1353bf798ba0d1a98e27d3fc4"/></dir><dir name="etc"><file name="api.xml" hash="9f11bf6ce08e658064fa06ae577dab61"/><file name="config.old" hash="32c8c8682c10d08fa11fc422ee29972d"/><file name="config.xml" hash="95769a56eb659528a597dd39d0b9010f"/></dir><dir name="sql"><dir name="vm2mage_setup"><file name="mysql4-install-0.5.4.php" hash="7897eff4982379777523254b6e37b90a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="vm2mage"><file name="check.phtml" hash="3e8e7562214ddb2d3c52f7f9c3e87ed2"/></dir></dir></dir></dir></dir></target></contents>
16
- <compatible/>
17
- <dependencies><required><php><min>5.2.8</min><max>6.0.0</max></php></required></dependencies>
18
- </package>
1
  <?xml version="1.0"?>
2
+ <package><name>Yireo_Vm2Mage</name><version>0.10.5</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>2013-06-05</date><time>4:33:37</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="code"><dir name="community"><dir name="Yireo"><dir name="Vm2Mage"><dir name="controllers"><file name="IndexController.php" hash="ca7164a56e0f2a4fffb598acfd2199af"/></dir><dir name="Block"><file name="Check.php" hash="6b892674344d6d2bdd8f061df34d3905"/></dir><dir name="etc"><file name="api.xml" hash="c4bf74c7a340a02ff1f095b5371472f9"/><file name="config.old" hash="32c8c8682c10d08fa11fc422ee29972d"/><file name="config.xml" hash="fcd6d4279d3e580f5e4d5d5c16c20066"/><file name="system.xml" hash="06eafb17e9fa31cbd63db69505ca7a9f"/></dir><dir name="sql"><dir name="vm2mage_setup"><file name="mysql4-install-0.10.3.php" hash="c8468feeed506515b538ae9f7ed8c0da"/><file name="mysql4-install-0.5.4.php" hash="de6658876bc68103fa099a814ffb46e0"/><file name="mysql4-upgrade-0.10.2-0.10.3.php" hash="1b08a11ed06b626f9edc6b86dc0f8bb9"/></dir></dir><dir name="Helper"><file name="Attribute.php" hash="35e1c22da300cbe5f72e663c6e3b64a0"/><file name="Category.php" hash="a80a6e7b5fe9b48cc8d80ca5d5a588f8"/><file name="Data.php" hash="241cebe4a1b4dbc4dfd1bf94b633a45a"/><file name="Image.php" hash="317d27310c453f63d7b1567ee895e6b9"/><file name="Price.php" hash="df91b573272cab2c1e6f86385a75bbae"/><file name="Product.php" hash="1a4566465b8bd931d96442d4243ca914"/><file name="Product.php.old" hash="be8e09d7fd14e1f054dd540c26da6542"/></dir><dir name="Model"><file name="Observer.php" hash="f0d803b0520bffdd7f14b56316efed0d"/><dir name="User"><file name="Api.php" hash="5f0a3e2398646ee2cefd227f421994ee"/></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="Category"><file name="Api.php" hash="25b451dde1a7cb690553d2bd91614047"/></dir><dir name="Widget"><file name="Api.php" hash="2fbfde9bcb5528f2148c8e9133b7622d"/></dir><dir name="Product"><file name="Api.php" hash="20d49dee2e9c19627eb373cae5f25cb5"/></dir><dir name="Order"><file name="Api.php" hash="a66d742bc5011749a84da412b1b8ce32"/></dir><dir name="Attribute"><file name="Api.php" hash="2abfe9a179d7e1f8a87d0be9f1b87a17"/></dir></dir></dir></dir></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="3e8e7562214ddb2d3c52f7f9c3e87ed2"/></dir></dir></dir></dir></dir></dir></dir></target></contents></package>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
skin/adminhtml/default/default/images/vm2mage/check-error.png ADDED
Binary file
skin/adminhtml/default/default/images/vm2mage/check-ok.png ADDED
Binary file
skin/adminhtml/default/default/images/vm2mage/check-warning.png ADDED
Binary file