Yireo_Vm2Mage - Version 0.7.196

Version Notes

See www.yireo.com/software for details

Download this release

Release Info

Developer Yireo
Extension Yireo_Vm2Mage
Version 0.7.196
Comparing to
See all releases


Code changes from version 0.7.136 to 0.7.196

Files changed (25) hide show
  1. app/code/community/Yireo/Vm2Mage/Block/Check.php +141 -0
  2. app/code/community/Yireo/Vm2Mage/Helper/Attribute.php +9 -15
  3. app/code/community/Yireo/Vm2Mage/Helper/Category.php +2 -2
  4. app/code/community/Yireo/Vm2Mage/Helper/Data.php +30 -12
  5. app/code/community/Yireo/Vm2Mage/Helper/Image.php +92 -12
  6. app/code/community/Yireo/Vm2Mage/Helper/Price.php +2 -2
  7. app/code/community/Yireo/Vm2Mage/Helper/Product.php +48 -71
  8. app/code/community/Yireo/Vm2Mage/Helper/Product.php.old +75 -0
  9. app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php +78 -48
  10. app/code/community/Yireo/Vm2Mage/Model/Category/Api.php +2 -2
  11. app/code/community/Yireo/Vm2Mage/Model/Observer.php +2 -2
  12. app/code/community/Yireo/Vm2Mage/Model/Order/Api.php +2 -2
  13. app/code/community/Yireo/Vm2Mage/Model/Product/Api.php +53 -22
  14. app/code/community/Yireo/Vm2Mage/Model/User/Api.php +2 -2
  15. app/code/community/Yireo/Vm2Mage/Model/Widget/Api.php +2 -2
  16. app/code/community/Yireo/Vm2Mage/controllers/IndexController.php +50 -0
  17. app/code/community/Yireo/Vm2Mage/etc/api.xml +2 -3
  18. app/code/community/Yireo/Vm2Mage/etc/config.old +132 -0
  19. app/code/community/Yireo/Vm2Mage/etc/config.xml +34 -2
  20. app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.5.4.php +2 -2
  21. app/design/adminhtml/default/default/template/vm2mage/check.phtml +47 -0
  22. package.xml +113 -11
  23. skin/adminhtml/default/default/images/vm2mage/check-error.png +0 -0
  24. skin/adminhtml/default/default/images/vm2mage/check-ok.png +0 -0
  25. skin/adminhtml/default/default/images/vm2mage/check-warning.png +0 -0
app/code/community/Yireo/Vm2Mage/Block/Check.php ADDED
@@ -0,0 +1,141 @@
1
+ <?php
2
+ /**
3
+ * Vm2Mage
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+
12
+ /*
13
+ * Vm2Mage class for the check-block
14
+ */
15
+ class Yireo_Vm2Mage_Block_Check extends Mage_Core_Block_Template
16
+ {
17
+ private $sytem_checks = array();
18
+
19
+ const CHECK_OK = 'ok';
20
+ const CHECK_WARNING = 'warning';
21
+ const CHECK_ERROR = 'error';
22
+
23
+ /*
24
+ * Constructor method
25
+ *
26
+ * @access public
27
+ * @param null
28
+ * @return null
29
+ */
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('vm2mage/check.phtml');
34
+ }
35
+
36
+ /*
37
+ * Helper to return the header of this page
38
+ *
39
+ * @access public
40
+ * @param string $title
41
+ * @return string
42
+ */
43
+ public function getHeader($title = null)
44
+ {
45
+ return 'Vm2Mage - '.$this->__($title);
46
+ }
47
+
48
+ /*
49
+ * Helper to return the menu
50
+ *
51
+ * @access public
52
+ * @param null
53
+ * @return string
54
+ */
55
+ public function getMenu()
56
+ {
57
+ return null;
58
+ }
59
+
60
+ /*
61
+ * Helper to add a check to this list
62
+ *
63
+ * @access public
64
+ * @param null
65
+ * @return string
66
+ */
67
+ private function addResult($group, $check, $status = 0, $description = '')
68
+ {
69
+ $checks = $this->system_checks;
70
+ $checks[$group][] = array(
71
+ 'check' => $this->__($check),
72
+ 'status' => $status,
73
+ 'description' => $this->__($description),
74
+ );
75
+
76
+ $this->system_checks = $checks;
77
+ return;
78
+ }
79
+
80
+ /*
81
+ * Check the license key
82
+ *
83
+ * @access public
84
+ * @param null
85
+ * @return string
86
+ */
87
+ public function getChecks()
88
+ {
89
+ $result = (version_compare(phpversion(), '5.2.8', '>=')) ? self::CHECK_OK : self::CHECK_ERROR;
90
+ $this->addResult('system', 'PHP version', $result, "PHP version 5.2.8 or higher is needed. A latest PHP version is always recommended.");
91
+
92
+ $current = ini_get('memory_limit');
93
+ $result = (version_compare($current, '255M', '>')) ? self::CHECK_OK : self::CHECK_WARNING;
94
+ $this->addResult('system', 'PHP memory', $result, "The minimum requirement for Magento itself is 256Mb. Current memory: ".$current);
95
+
96
+ $result = (function_exists('json_decode')) ? self::CHECK_OK : self::CHECK_ERROR;
97
+ $this->addResult('system', 'JSON', $result, 'The JSON-extension for PHP is needed');
98
+
99
+ $result = (function_exists('curl_init')) ? self::CHECK_OK : self::CHECK_ERROR;
100
+ $this->addResult('system', 'CURL', $result, 'The CURL-extension for PHP is needed');
101
+
102
+ $result = (function_exists('simplexml_load_string')) ? self::CHECK_OK : self::CHECK_ERROR;
103
+ $this->addResult('system', 'SimpleXML', $result, 'The SimpleXML-extension for PHP is needed');
104
+
105
+ $result = (in_array('ssl', stream_get_transports())) ? self::CHECK_OK : self::CHECK_WARNING;
106
+ $this->addResult('system', 'OpenSSL', $result, 'PHP support for OpenSSL is needed if you want to use HTTPS');
107
+
108
+ $result = (function_exists('iconv')) ? self::CHECK_OK : self::CHECK_ERROR;
109
+ $this->addResult('system', 'iconv', $result, 'The iconv-extension for PHP is needed');
110
+
111
+ $result = (ini_get('safe_mode')) ? self::CHECK_ERROR : self::CHECK_OK;
112
+ $this->addResult('system', 'Safe Mode', $result, 'PHP Safe Mode is strongly outdated and not supported by either Joomla! or Magento');
113
+
114
+ $result = (ini_get('magic_quotes_gpc')) ? self::CHECK_ERROR : self::CHECK_OK;
115
+ $this->addResult('system', 'Magic Quotes GPC', $result, 'Magic Quotes GPC is outdated and should be disabled');
116
+
117
+ $remote_domain = 'api.yireo.com';
118
+ $result = (@fsockopen($remote_domain, 80, $errno, $errmsg, 5)) ? self::CHECK_OK : self::CHECK_ERROR;
119
+ $this->addResult('system', 'Firewall', $result, 'Firewall needs to allow outgoing access on port 80.');
120
+
121
+ $logfile = Mage::helper('vm2mage')->getDebugLog();
122
+ $result = (@is_writable($logfile)) ? self::CHECK_OK : self::CHECK_ERROR;
123
+ $this->addResult('system', 'Logfile', $result, 'Logfile "'.$logfile.'" should be writable');
124
+
125
+ $import_dir = Mage::getBaseDir('media').DS.'import';
126
+ if(!is_dir($import_dir)) @mkdir($import_dir);
127
+ $result = (@is_writable($import_dir)) ? self::CHECK_OK : self::CHECK_ERROR;
128
+ $this->addResult('system', 'Import folder', $result, 'Import-folder "'.$import_dir.'" should be writable');
129
+
130
+ $catalog_dir = Mage::getBaseDir('media').DS.'catalog';
131
+ if(!is_dir($catalog_dir)) @mkdir($catalog_dir);
132
+ $result = (@is_writable($catalog_dir)) ? self::CHECK_OK : self::CHECK_ERROR;
133
+ $this->addResult('system', 'Catalog folder', $result, 'Catalog-folder "'.$catalog_dir.'" should be writable');
134
+
135
+ $collection = Mage::getResourceModel('api/user_collection');
136
+ $result = ($collection->count() > 0) ? self::CHECK_OK : self::CHECK_ERROR;
137
+ $this->addResult('system', 'API-user', $result, 'You should create an API-user with API resource-access');
138
+
139
+ return $this->system_checks;
140
+ }
141
+ }
app/code/community/Yireo/Vm2Mage/Helper/Attribute.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -37,20 +37,12 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
37
* Method to get an attribute by its code
38
*
39
* @param Mage_Catalog_Model_Product $product
40
- * @param string $attribute_code
41
- * @param string $attribute_value
42
- * @return Mage_Catalog_Model_Product`
43
*/
44
- public function getAttributeByCode($attribute_code = null)
45
{
46
- $attributeSetId = Mage::getModel('catalog/product')->getDefaultAttributeSetId();
47
- $attributes = Mage::getModel('catalog/product')->setAttributeSetId($attributeSetId)->getAttributes();
48
- $attribute = null;
49
- foreach ($attributes as $attribute) {
50
- if($attribute->getAttributeCode() == $attribute_code) {
51
- break;
52
- }
53
- }
54
return $attribute;
55
}
56
@@ -89,7 +81,9 @@ class Yireo_Vm2Mage_Helper_Attribute extends Yireo_Vm2Mage_Helper_Data
89
if(!empty($method)) {
90
try {
91
$product->$method($value);
92
- } catch(Exception $e) {}
93
}
94
95
return $product;
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
37
* Method to get an attribute by its code
38
*
39
* @param Mage_Catalog_Model_Product $product
40
+ * @param string $attributeCode
41
+ * @return Mage_Catalog_Model_Product
42
*/
43
+ public function getAttributeByCode($attributeCode = null)
44
{
45
+ $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attributeCode);
46
return $attribute;
47
}
48
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
89
return $product;
app/code/community/Yireo/Vm2Mage/Helper/Category.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Helper/Data.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -30,6 +30,29 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
30
return $prefix.ucfirst($string);
31
}
32
33
/*
34
* Helper-method to quickly log a debug-entry
35
*
@@ -44,15 +67,9 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
44
$string .= ': '.var_export($mixed, true);
45
}
46
47
- // Try to create the log-directory if it does not exist
48
- $log_dir = Mage::getBaseDir().DS.'var'.DS.'log';
49
- if(is_dir($log_dir) && is_writable($log_dir)) {
50
- @mkdir(Mage::getBaseDir().DS.'var');
51
- @mkdir($log_dir);
52
- }
53
-
54
- if(is_dir($log_dir) && is_writable($log_dir)) {
55
- @file_put_contents($log_dir.DS.'vm2mage.log', $string."\n", FILE_APPEND);
56
}
57
}
58
@@ -80,7 +97,8 @@ class Yireo_Vm2Mage_Helper_Data extends Mage_Core_Helper_Abstract
80
foreach($array as $name => $value) {
81
if(is_array($value)) {
82
$value = Mage::helper('vm2mage')->decode($value);
83
- } elseif(!empty($value)) {
84
$value = base64_decode($value);
85
}
86
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
30
return $prefix.ucfirst($string);
31
}
32
33
+ /*
34
+ * Helper-method to return the log filename
35
+ *
36
+ * @param null
37
+ * @return string
38
+ */
39
+ public function getDebugLog()
40
+ {
41
+ // Try to create the log-directory if it does not exist
42
+ $log_dir = Mage::getBaseDir().DS.'var'.DS.'log';
43
+ if(!is_dir($log_dir) && !is_writable($log_dir)) {
44
+ @mkdir(Mage::getBaseDir().DS.'var');
45
+ @mkdir($log_dir);
46
+ }
47
+
48
+ $log_file = $log_dir.DS.'vm2mage.log';
49
+ if(!file_exists($log_file)) {
50
+ @touch($log_file);
51
+ }
52
+
53
+ return $log_file;
54
+ }
55
+
56
/*
57
* Helper-method to quickly log a debug-entry
58
*
67
$string .= ': '.var_export($mixed, true);
68
}
69
70
+ $logfile = self::getDebugLog();
71
+ if(@is_writable($logfile)) {
72
+ @file_put_contents($logfile, $string."\n", FILE_APPEND);
73
}
74
}
75
97
foreach($array as $name => $value) {
98
if(is_array($value)) {
99
$value = Mage::helper('vm2mage')->decode($value);
100
+ } elseif(!empty($value) && preg_match('/^V2M___/', $value)) {
101
+ $value = preg_replace('/^V2M___/', '', $value);
102
$value = base64_decode($value);
103
}
104
app/code/community/Yireo/Vm2Mage/Helper/Image.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -22,10 +22,26 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
22
*/
23
public function getRemoteContent($url = null)
24
{
25
- if(!empty($url)) {
26
$content = file_get_contents($url);
27
return $content;
28
}
29
return null;
30
}
31
@@ -36,7 +52,7 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
36
* @param array $images
37
* @return Mage_Catalog_Model_Product $product
38
*/
39
- public function addRemoteImages($product = null, $images = null)
40
{
41
// Check whether the images are already there
42
$gallery_images = $product->getMediaGalleryImages();
@@ -47,7 +63,17 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
47
// Loop through the images and create them
48
if(is_array($images) && !empty($images)) {
49
foreach($images as $image) {
50
- $product = self::addRemoteImage($product, $image['url'], $image['md5sum'], $image['type'], $image['label']);
51
}
52
}
53
@@ -94,26 +120,80 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
94
95
// Try to create the import-directory it it does not exist
96
$base_dir = Mage::getBaseDir('media').DS.'import';
97
- if(!is_dir($base_dir)) {
98
- @mkdir($base_dir);
99
- }
100
101
// If this fails, return without creating images
102
if(!is_dir($base_dir)) {
103
- Mage::helper('vm2mage')->debug('Image folder does not exist', $base_dir);
104
- return $product;
105
}
106
107
// Create a temporary file
108
$tmp_file = $base_dir.DS.basename($url);
109
110
- // Get the remote image and write it to the temporary file
111
$tmp_content = self::getRemoteContent($url);
112
file_put_contents($tmp_file, $tmp_content);
113
114
// Check the MD5 sum of this file
115
if(!empty($md5sum) && md5_file($tmp_file) != $md5sum) {
116
- Mage::helper('vm2mage')->debug('Image does not match', $tmp_file);
117
return false;
118
}
119
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
22
*/
23
public function getRemoteContent($url = null)
24
{
25
+ if(empty($url)) {
26
+ return null;
27
+ }
28
+
29
+ if(function_exists('curl_init')) {
30
+ $conn = curl_init($url) ;
31
+ curl_setopt($conn, CURLOPT_HEADER, 0);
32
+ curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
33
+ curl_setopt($conn, CURLOPT_SSL_VERIFYHOST, 0);
34
+ curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, 0);
35
+ $content = curl_exec($conn);
36
+ curl_close($conn);
37
+ return $content;
38
+
39
+ } elseif(ini_get( 'allow_url_fopen')) {
40
$content = file_get_contents($url);
41
return $content;
42
}
43
+
44
+ Mage::helper('vm2mage')->debug('No download-methods available');
45
return null;
46
}
47
52
* @param array $images
53
* @return Mage_Catalog_Model_Product $product
54
*/
55
+ public function addImages($product = null, $images = null)
56
{
57
// Check whether the images are already there
58
$gallery_images = $product->getMediaGalleryImages();
63
// Loop through the images and create them
64
if(is_array($images) && !empty($images)) {
65
foreach($images as $image) {
66
+
67
+ if(empty($image['label'])) $image['label'] = $product->getName();
68
+ $result = self::addLocalImage($product, $image['file'], $image['label']);
69
+ if($result != false) {
70
+ $product = $result;
71
+ } else {
72
+ $result = self::addRemoteImage($product, $image['url'], $image['md5sum'], $image['type'], $image['label']);
73
+ if($result != false) {
74
+ $product = $result;
75
+ }
76
+ }
77
}
78
}
79
120
121
// Try to create the import-directory it it does not exist
122
$base_dir = Mage::getBaseDir('media').DS.'import';
123
+ if(!is_dir($base_dir)) @mkdir($base_dir);
124
125
// If this fails, return without creating images
126
if(!is_dir($base_dir)) {
127
+ Mage::helper('vm2mage')->debug('ERROR: Image folder does not exist', $base_dir);
128
+ return false;
129
}
130
131
// Create a temporary file
132
$tmp_file = $base_dir.DS.basename($url);
133
134
+ // Get the remote image
135
$tmp_content = self::getRemoteContent($url);
136
+ if(empty($tmp_content)) {
137
+ Mage::helper('vm2mage')->debug('ERROR: Image-download from '.$url.' returns empty');
138
+ @unlink($tmp_file);
139
+ return false;
140
+ }
141
+
142
+ // Write it to the temporary file
143
file_put_contents($tmp_file, $tmp_content);
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 does not match', $tmp_file);
148
+ return false;
149
+ }
150
+
151
+ // Add the image to the gallery
152
+ $product = $product->addImageToMediaGallery($tmp_file, 'media_gallery', true, false);
153
+
154
+ // Clean temporary file if needed
155
+ if(file_exists($tmp_file)) {
156
+ unlink($tmp_file);
157
+ }
158
+
159
+ // Return the changed product-object
160
+ return $product;
161
+ }
162
+
163
+ /*
164
+ * Add a remote image to this product (and check its md5sum)
165
+ *
166
+ * @param Mage_Catalog_Model_Product $product
167
+ * @param string $file
168
+ * @param string $type
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)
173
+ {
174
+ // Try to create the import-directory it it does not exist
175
+ $base_dir = Mage::getBaseDir('media').DS.'import';
176
+ if(is_dir($base_dir) == false) {
177
+ @mkdir($base_dir);
178
+ }
179
+
180
+ // If this fails, return without creating images
181
+ if(is_dir($base_dir) == false) {
182
+ Mage::helper('vm2mage')->debug('ERROR: Image folder does not exist', $base_dir);
183
+ return false;
184
+ }
185
+
186
+ if(@is_readable($file) == false) {
187
+ Mage::helper('vm2mage')->debug('ERROR: Image is not readable', $file);
188
+ return false;
189
+ }
190
+
191
+ // Create a temporary file
192
+ $tmp_file = $base_dir.DS.basename($file);
193
+
194
+ // Get the remote image and write it to the temporary file
195
+ if(@copy($file, $tmp_file) == false) {
196
+ Mage::helper('vm2mage')->debug('ERROR: Copy new image to image-folder failed', $base_dir);
197
return false;
198
}
199
app/code/community/Yireo/Vm2Mage/Helper/Price.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Helper/Product.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -20,90 +20,67 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
20
* @param array $values
21
* @return array
22
*/
23
- public function addChildrenToConfigurable($child_skus = array(), $attribute_codes = array(), $product = null)
24
{
25
- $children = array();
26
- $child_ids = array();
27
- foreach($child_skus as $child_sku) {
28
- $child_id = Mage::getModel('catalog/product')->getIdBySku($child_sku);
29
- $child = Mage::getModel('catalog/product')->load($child_id);
30
- $child_ids[] = $child_id;
31
- $children[] = $child;
32
}
33
- //Mage::getResourceModel('catalog/product_type_configurable')->saveProducts($product->getId(), $children);
34
35
- $product_super_attributes = $product->getTypeInstance()->getConfigurableAttributesAsArray();
36
37
$i = 0;
38
- $configurable_attributes_data = array();
39
- $configurable_products_data = array();
40
- $child_set_prices = array();
41
-
42
foreach($attribute_codes as $attribute_code) {
43
-
44
- $attribute = Mage::helper('vm2mage/attribute')->getAttributeByCode($attribute_code);
45
- $attribute_method = Mage::helper('vm2mage')->stringToMethod($attribute_code, 'get');
46
-
47
- $product_super_attribute_id = null;
48
- if(!empty($product_super_attributes)) {
49
- foreach($product_super_attributes as $p) {
50
- if($p['attribute_code'] == $attribute->getAttributeCode()) {
51
- $product_super_attribute_id = $p['id'];
52
- break;
53
- }
54
}
55
}
56
57
- $values = array();
58
- foreach($children as $child) {
59
-
60
- $child_label = $attribute->getFrontend()->getValue($child);
61
- $child_value = $child->$attribute_method();
62
- $child_price = $child->getPrice();
63
- $child_price_difference = $child_price - $product->getPrice();
64
-
65
- // If there's a price difference between this subproduct and the parent, fill it in once
66
- if(!in_array($child->getId(), $child_set_prices) && $child_price_difference > 0) {
67
- $child_set_prices[] = $child->getId();
68
- } else {
69
- $child_price_difference = null;
70
}
71
72
- $values[] = array(
73
- 'product_super_attribute_id' => $product_super_attribute_id,
74
- 'value_index' => $child_value,
75
- 'label' => $child_label,
76
- 'default_label' => $child_label,
77
- 'store_label' => $child_label,
78
- 'is_percent' => 0,
79
- 'pricing_value' => $child_price_difference,
80
- 'use_default_value' => true,
81
- );
82
83
- $configurable_products_data[$child->getId()][] = array(
84
- 'attribute_id' => $attribute->getId(),
85
- 'label' => $child_label,
86
- 'value_index' => $child_value,
87
- );
88
}
89
-
90
- $configurable_attributes_data[] = array(
91
- 'id' => $product_super_attribute_id,
92
- 'label' => $attribute->getFrontendLabel(),
93
- 'position' => null,
94
- 'values' => $values,
95
- 'attribute_id' => $attribute->getId(),
96
- 'attribute_code' => $attribute->getAttributeCode(),
97
- 'frontend_label' => $attribute->getFrontendLabel(),
98
- 'html_id' => 'config_super_product__attribute_'.$i,
99
- );
100
- $i++;
101
}
102
103
- //Mage::helper('vm2mage')->debug('Configurable Products Data', $configurable_products_data);
104
- Mage::helper('vm2mage')->debug('Configurable Attributes Data', $configurable_attributes_data);
105
- $product->setConfigurableProductsData($configurable_products_data);
106
- $product->setConfigurableAttributesData($configurable_attributes_data);
107
108
// Try to safe this product to the database
109
try {
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
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();
27
+ foreach($children as $child) {
28
+ $childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
29
+ if(empty($childId)) {
30
+ Mage::getModel('vm2mage/product_api')->migrate($child);
31
+ $childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
32
+ }
33
+ $childIds[] = $childId;
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
41
+ $attributeData = array();
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
}
51
}
52
+ }
53
54
+ if(!empty($childIds)) {
55
+ foreach($childIds as $childId) {
56
+ $productData[$childId] = array();
57
+ foreach($attributeIds as $attributeId) {
58
+ $productData[$childId][] = array('attribute_id' => $attributeId);
59
}
60
+ }
61
+ }
62
63
+ // Insert the used product-attributes if they do not exist yet
64
+ $currentProductAttributeIds = $product->getTypeInstance()->getUsedProductAttributeIds();
65
+ if(empty($currentProductAttributeIds)) {
66
+ $product->getTypeInstance()->setUsedProductAttributeIds($attributeIds);
67
+ }
68
69
+ // Insert the attribute-data
70
+ $attributeData = $product->getTypeInstance()->getConfigurableAttributesAsArray();
71
+ foreach($attributeData as $key => $attribute) {
72
+ if(empty($attribute['label'])) {
73
+ $attributeData[$key]['label'] = $attribute['frontend_label'];
74
}
75
}
76
+ $product->setConfigurableAttributesData($attributeData, $product);
77
+ $product->setCanSaveConfigurableAttributes(true);
78
+ $product->setCanSaveCustomOptions(true);
79
80
+ // Insert the product-data
81
+ if(!empty($productData)) {
82
+ $product->setConfigurableProductsData($productData, $product);
83
+ }
84
85
// Try to safe this product to the database
86
try {
app/code/community/Yireo/Vm2Mage/Helper/Product.php.old ADDED
@@ -0,0 +1,75 @@
1
+ <?php
2
+ /**
3
+ * Yireo Vm2Mage for Magento
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+
12
+ /**
13
+ * Vm2Mage helper
14
+ */
15
+ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
16
+ {
17
+ /*
18
+ * Helper-method to convert a regular array to the options-structure required by the Attribute-model
19
+ *
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();
27
+ foreach($children as $child) {
28
+ Mage::getModel('vm2mage/product_api')->migrate($child);
29
+ $childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
30
+ $childIds[] = $childId;
31
+ }
32
+
33
+ // Insert the Simple Products that belong in this Configurable Product
34
+ $loader = Mage::getResourceModel('catalog/product_type_configurable')->load($product);
35
+ $loader->saveProducts($product, $childIds);
36
+
37
+ // Gather the attribute-objects for use in this Configurable Product
38
+ $usedAttributeIds = array();
39
+ foreach($attribute_codes as $attribute_code) {
40
+ $attribute = $product->getResource()->getAttribute($attribute_code);
41
+ if($product->getTypeInstance()->canUseAttribute($attribute)) {
42
+ $usedAttributeIds[] = $attribute->getAttributeId();
43
+ }
44
+ }
45
+
46
+ // Insert the attributes that belong in this Configurable Product
47
+ if(!empty($usedAttributeIds)) {
48
+
49
+ // Set the attribute-IDs for this product
50
+ $product->getTypeInstance()->setUsedProductAttributeIds($usedAttributeIds, $product);
51
+
52
+ // Get the attributes-data and parse it a bit
53
+ $attributesData = $product->getTypeInstance()->getConfigurableAttributesAsArray();
54
+ foreach($attributesData as $key => $attribute_value) {
55
+ $attributesData[$key]['label'] = $attribute_value['frontend_label'];
56
+ }
57
+ Mage::helper('vm2mage')->debug('Configurable Product Attributes', $attributesData);
58
+
59
+ // Insert the attributes-data into the product
60
+ $product->setConfigurableAttributesData($attributesData);
61
+ $product->setCanSaveConfigurableAttributes(true);
62
+
63
+ //$product->setCanSaveCustomOptions(true);
64
+ //$product->setProductOptions(); ???
65
+ }
66
+
67
+ // Try to safe this product to the database
68
+ try {
69
+ $product->save();
70
+ } catch(Exception $e) {
71
+ return array(0, $e->getMessage());
72
+ }
73
+ }
74
+ }
75
+
app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -23,66 +23,96 @@ 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
27
- // Get a clean product-object
28
- $attribute = Mage::getModel('catalog/entity_attribute');
29
-
30
- // Try to load this attribute by its code
31
$data['name'] = strtolower($data['name']);
32
- $attribute->loadByCode('catalog_product', $data['name']);
33
34
if(!$attribute->getId() > 0) {
35
- $attribute->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId());
36
- $attribute->setIsUserDefined(1);
37
}
38
39
- // Create a default attribute
40
- $attribute
41
- ->setAttributeCode($data['name'])
42
- ->setIsComparable(0)
43
- ->setIsConfigurable(1)
44
- ->setIsFilterable(0)
45
- ->setIsFilterableInSearch(0)
46
- ->setIsGlobal(1)
47
- ->setIsRequired(0)
48
- ->setIsSearchable(0)
49
- ->setIsUnique(0)
50
- ->setIsUsedForPriceRules(0)
51
- ->setIsVisibleInAdvancedSearch(0)
52
- ->setIsVisibleOnFront(0)
53
- ->setDefaultValueYesno(0)
54
- ->setUsedInProductListing(0)
55
- ->setFrontendInput('select')
56
- ->setFrontendLabel(array($data['label'], $data['label']))
57
- ->setBackendType($attribute->getBackendTypeByInput('select'))
58
- ;
59
60
- // Set the attribute options (but only for new attributes)
61
- if(!$attribute->getId() > 0) {
62
$options = Mage::helper('vm2mage/attribute')->valueToOptions($data['values']);
63
$attribute->setOption($options);
64
}
65
66
- // Add other data
67
- $adata = array();
68
- $adata['backend_model'] = 'eav/entity_attribute_backend_array';
69
- $adata['apply_to'] = array();
70
- $attribute->addData($adata);
71
-
72
- // Add it to the default attribute-set and the first group
73
- $attributeSetId = Mage::getModel('catalog/product')->getDefaultAttributeSetId();
74
- $groups = Mage::getModel('eav/entity_attribute_group')
75
- ->getResourceCollection()
76
- ->setAttributeSetFilter($attributeSetId)
77
- ->load();
78
- foreach($groups as $group) break;
79
- if(!empty($group)) {
80
- $attribute->setAttributeSetId($attributeSetId);
81
- $attribute->setAttributeGroupId($group->getAttributeGroupId());
82
}
83
84
// Save the attribute
85
- $attribute->save();
86
87
return array(1, "Successfully saved attribute '".$data['name']."'");
88
}
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
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)
56
+ ->setIsRequired(0)
57
+ ->setIsSearchable(0)
58
+ ->setIsUnique(0)
59
+ ->setIsUserDefined(1)
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
71
+ $attributeSetId = Mage::getModel('catalog/product')->getDefaultAttributeSetId();
72
+ $groups = Mage::getModel('eav/entity_attribute_group')
73
+ ->getResourceCollection()
74
+ ->setAttributeSetFilter($attributeSetId)
75
+ ->load();
76
+ foreach($groups as $group) break;
77
+ if(!empty($group)) {
78
+ $attribute->setAttributeSetId($attributeSetId);
79
+ $attribute->setAttributeGroupId($group->getAttributeGroupId());
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
88
+ $existing_options = array();
89
+ foreach($attribute->getSource()->getAllOptions(false) as $existing_option) {
90
+ $existing_options[] = $existing_option['label'];
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
}
app/code/community/Yireo/Vm2Mage/Model/Category/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Model/Observer.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Model/Order/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Model/Product/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
@@ -27,8 +27,12 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
27
28
// Decode all values
29
$data = Mage::helper('vm2mage')->decode($data);
30
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
31
32
// Get a clean product-object
33
$product = Mage::getModel('catalog/product');
34
@@ -63,7 +67,6 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
63
64
// Set common attributes
65
$product->setData($product->getData())
66
- ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
67
->setStoreId($storeId)
68
->setWebsiteIds(array(Mage::getModel('core/store')->load($storeId)->getWebsiteId()))
69
->setSku($data['sku'])
@@ -75,34 +78,57 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
75
->setTaxClassId($taxId)
76
;
77
78
- // Set Meta-information
79
- //$product->setMetaDescription();
80
- //$product->setMetaTitle();
81
- //$product->setMetaKeywords();
82
-
83
- // @todo: Set the per-product attributes
84
- /*
85
- if(isset($data['attribute'])) {
86
- foreach($data['attribute'] as $name => $value) {
87
- $product = Mage::helper('vm2mage/attribute')->addAttributeToProduct($product, $name, $value);
88
- }
89
}
90
- */
91
92
// Set the custom attributes
93
if(isset($data['attributes'])) {
94
foreach($data['attributes'] as $name => $value) {
95
$product = Mage::helper('vm2mage/attribute')->addAttributeToProduct($product, $name, $value);
96
}
97
}
98
99
// Set the price
100
// @todo: Include support for tier pricing
101
- // @todo: Include support for special pricing
102
if(isset($data['price']['product_price'])) {
103
$product->setPrice($data['price']['product_price']);
104
}
105
106
// Convert the category-IDs
107
if(!empty($data['category_ids'])) {
108
$category_ids = array();
@@ -116,29 +142,34 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
116
}
117
}
118
119
- //$product->setIsMassupdate(true);
120
- //$product->setExcludeUrlRewrite(true);
121
122
// Get the remote images
123
if(isset($data['images'])) {
124
try {
125
- $product = Mage::helper('vm2mage/image')->addRemoteImages($product, $data['images']);
126
} catch(Exception $e) {
127
return array(0, $e->getMessage());
128
}
129
}
130
131
- // Try to safe this product to the database
132
try {
133
$product->save();
134
- Mage::dispatchEvent('catalog_product_prepare_save', array('product' => $product));
135
} catch(Exception $e) {
136
return array(0, $e->getMessage());
137
}
138
139
// Configure this product as configurable product
140
if($data['has_children'] > 0) {
141
- Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], $data['attributes_sku'], $product);
142
}
143
144
// Return true by default
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
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');
38
67
68
// Set common attributes
69
$product->setData($product->getData())
70
->setStoreId($storeId)
71
->setWebsiteIds(array(Mage::getModel('core/store')->load($storeId)->getWebsiteId()))
72
->setSku($data['sku'])
78
->setTaxClassId($taxId)
79
;
80
81
+ // Set visibility
82
+ if(isset($data['visibility']) && $data['visibility'] == 'none') {
83
+ $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
84
+ } else {
85
+ $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
86
}
87
+
88
+ // Set Meta-information
89
+ $product->setMetaDescription(strip_tags($product->getDescription()));
90
+ $product->setMetaTitle($product->getTitle());
91
92
// Set the custom attributes
93
if(isset($data['attributes'])) {
94
foreach($data['attributes'] as $name => $value) {
95
+ //Mage::helper('vm2mage')->debug('Product attribute', $name);
96
$product = Mage::helper('vm2mage/attribute')->addAttributeToProduct($product, $name, $value);
97
}
98
}
99
100
// Set the price
101
// @todo: Include support for tier pricing
102
if(isset($data['price']['product_price'])) {
103
$product->setPrice($data['price']['product_price']);
104
}
105
106
+ // Set the special price
107
+ if(isset($data['special_price']['price'])) {
108
+ $product->setSpecialPrice($data['special_price']['price']);
109
+ }
110
+
111
+ // Set the special price from-date
112
+ if(isset($data['special_price']['start_date'])) {
113
+ $product->setSpecialFromDate($data['special_price']['start_date']);
114
+ }
115
+
116
+ // Set the special price from-date
117
+ if(isset($data['special_price']['end_date'])) {
118
+ $product->setSpecialToDate($data['special_price']['end_date']);
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
+ $stockItem->setData($stockData);
129
+ $product->setStockItem($stockItem);
130
+ }
131
+
132
// Convert the category-IDs
133
if(!empty($data['category_ids'])) {
134
$category_ids = array();
142
}
143
}
144
145
+ // Set the mass-update flags to prevent reindexing for now
146
+ $product->setIsMassupdate(true);
147
+ $product->setExcludeUrlRewrite(true);
148
149
// Get the remote images
150
if(isset($data['images'])) {
151
try {
152
+ $product = Mage::helper('vm2mage/image')->addImages($product, $data['images']);
153
} catch(Exception $e) {
154
return array(0, $e->getMessage());
155
}
156
}
157
158
+ // Try to save this product to the database
159
try {
160
+ $request = Mage::app()->getFrontController()->getRequest();
161
+ Mage::dispatchEvent('catalog_product_prepare_save', array('product' => $product, 'request' => $request));
162
$product->save();
163
} catch(Exception $e) {
164
return array(0, $e->getMessage());
165
}
166
167
// Configure this product as configurable product
168
if($data['has_children'] > 0) {
169
+ $rs = Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], $data['attributes_sku'], $product);
170
+ if(!empty($rs)) {
171
+ return $rs;
172
+ }
173
}
174
175
// Return true by default
app/code/community/Yireo/Vm2Mage/Model/User/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/Model/Widget/Api.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/code/community/Yireo/Vm2Mage/controllers/IndexController.php ADDED
@@ -0,0 +1,50 @@
1
+ <?php
2
+ /**
3
+ * Vm2Mage
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+
12
+ /**
13
+ * Vm2Mage admin controller
14
+ */
15
+ class Yireo_Vm2Mage_IndexController extends Mage_Adminhtml_Controller_Action
16
+ {
17
+ /**
18
+ * Common method to initialize each action
19
+ *
20
+ * @access protected
21
+ * @param null
22
+ * @return $this
23
+ */
24
+ protected function _initAction()
25
+ {
26
+ // Load the layout
27
+ $this->loadLayout()
28
+ ->_setActiveMenu('system/tools/vm2mage')
29
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'))
30
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tools'), Mage::helper('adminhtml')->__('Tools'))
31
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Vm2Mage System Check'), Mage::helper('adminhtml')->__('Vm2Mage System Check'))
32
+ ;
33
+
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * System Check page
39
+ *
40
+ * @access public
41
+ * @param null
42
+ * @return null
43
+ */
44
+ public function indexAction()
45
+ {
46
+ $this->_initAction()
47
+ ->_addContent($this->getLayout()->createBlock('vm2mage/check'))
48
+ ->renderLayout();
49
+ }
50
+ }
app/code/community/Yireo/Vm2Mage/etc/api.xml CHANGED
@@ -5,14 +5,13 @@
5
*
6
* @author Yireo
7
* @package Vm2Mage
8
- * @copyright Copyright 2009
9
- * @license Yireo EULA (www.yireo.com)
10
* @link http://www.yireo.com
11
*/
12
-->
13
<config>
14
<api>
15
-
16
<resources>
17
<vm2mage_widget translate="title" module="vm2mage">
18
<model>vm2mage/widget_api</model>
5
*
6
* @author Yireo
7
* @package Vm2Mage
8
+ * @copyright Copyright 2011
9
+ * @license Open Source License
10
* @link http://www.yireo.com
11
*/
12
-->
13
<config>
14
<api>
15
<resources>
16
<vm2mage_widget translate="title" module="vm2mage">
17
<model>vm2mage/widget_api</model>
app/code/community/Yireo/Vm2Mage/etc/config.old ADDED
@@ -0,0 +1,132 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Yireo Vm2Mage for Magento
5
+ *
6
+ * @author Yireo
7
+ * @package Vm2Mage
8
+ * @copyright Copyright 2011
9
+ * @license Yireo EULA (www.yireo.com)
10
+ * @link http://www.yireo.com
11
+ */
12
+ -->
13
+ <config>
14
+
15
+ <modules>
16
+ <Yireo_Vm2Mage>
17
+ <version>0.7.97</version>
18
+ </Yireo_Vm2Mage>
19
+ </modules>
20
+
21
+ <global>
22
+ <blocks>
23
+ <vm2mage>
24
+ <class>Yireo_Vm2Mage_Block</class>
25
+ </vm2mage>
26
+ </blocks>
27
+
28
+ <helpers>
29
+ <vm2mage>
30
+ <class>Yireo_Vm2Mage_Helper</class>
31
+ </vm2mage>
32
+ </helpers>
33
+
34
+ <models>
35
+ <vm2mage>
36
+ <class>Yireo_Vm2Mage_Model</class>
37
+ </vm2mage>
38
+ </models>
39
+
40
+ <resources>
41
+ <vm2mage_setup>
42
+ <setup>
43
+ <module>Yireo_Vm2Mage</module>
44
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </vm2mage_setup>
50
+ <vm2mage_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </vm2mage_write>
55
+ <vm2mage_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </vm2mage_read>
60
+ </resources>
61
+
62
+ </global>
63
+
64
+ <adminhtml>
65
+ <translate>
66
+ <modules>
67
+ <Yireo_Vm2Mage>
68
+ <files>
69
+ <default>Yireo_Vm2Mage.csv</default>
70
+ </files>
71
+ </Yireo_Vm2Mage>
72
+ </modules>
73
+ </translate>
74
+ <menu>
75
+ <system>
76
+ <children>
77
+ <tools>
78
+ <children>
79
+ <vm2mage translate="title" module="vm2mage">
80
+ <title>Vm2Mage System Check</title>
81
+ <action>vm2mage/index</action>
82
+ </vm2mage>
83
+ </children>
84
+ </tools>
85
+ </children>
86
+ </system>
87
+ </menu>
88
+ <acl>
89
+ <resources>
90
+ <admin>
91
+ <children>
92
+ <system>
93
+ <children>
94
+ <config>
95
+ <children>
96
+ <vm2mage translate="title" module="vm2mage">
97
+ <title>Vm2Mage Section</title>
98
+ </vm2mage>
99
+ </children>
100
+ </config>
101
+ </children>
102
+ </system>
103
+ </children>
104
+ </admin>
105
+ </resources>
106
+ </acl>
107
+ <events>
108
+ <catalog_category_delete_after>
109
+ <observers>
110
+ <vm2mage_observer>
111
+ <type>singleton</type>
112
+ <class>vm2mage/observer</class>
113
+ <method>catalogCategoryDeleteAfter</method>
114
+ </vm2mage_observer>
115
+ </observers>
116
+ </catalog_category_delete_after>
117
+ </events>
118
+ </adminhtml>
119
+
120
+ <admin>
121
+ <routers>
122
+ <vm2mage>
123
+ <use>admin</use>
124
+ <args>
125
+ <module>Yireo_Vm2Mage</module>
126
+ <frontName>vm2mage</frontName>
127
+ </args>
128
+ </vm2mage>
129
+ </routers>
130
+ </admin>
131
+
132
+ </config>
app/code/community/Yireo/Vm2Mage/etc/config.xml CHANGED
@@ -5,7 +5,7 @@
5
*
6
* @author Yireo
7
* @package Vm2Mage
8
- * @copyright Copyright 2009
9
* @license Yireo EULA (www.yireo.com)
10
* @link http://www.yireo.com
11
*/
@@ -14,11 +14,17 @@
14
15
<modules>
16
<Yireo_Vm2Mage>
17
- <version>0.7.136</version>
18
</Yireo_Vm2Mage>
19
</modules>
20
21
<global>
22
<helpers>
23
<vm2mage>
24
<class>Yireo_Vm2Mage_Helper</class>
@@ -65,6 +71,20 @@
65
</Yireo_Vm2Mage>
66
</modules>
67
</translate>
68
<acl>
69
<resources>
70
<admin>
@@ -97,4 +117,16 @@
97
</events>
98
</adminhtml>
99
100
</config>
5
*
6
* @author Yireo
7
* @package Vm2Mage
8
+ * @copyright Copyright 2011
9
* @license Yireo EULA (www.yireo.com)
10
* @link http://www.yireo.com
11
*/
14
15
<modules>
16
<Yireo_Vm2Mage>
17
+ <version>0.7.196</version>
18
</Yireo_Vm2Mage>
19
</modules>
20
21
<global>
22
+ <blocks>
23
+ <vm2mage>
24
+ <class>Yireo_Vm2Mage_Block</class>
25
+ </vm2mage>
26
+ </blocks>
27
+
28
<helpers>
29
<vm2mage>
30
<class>Yireo_Vm2Mage_Helper</class>
71
</Yireo_Vm2Mage>
72
</modules>
73
</translate>
74
+ <menu>
75
+ <system>
76
+ <children>
77
+ <tools>
78
+ <children>
79
+ <vm2mage translate="title" module="vm2mage">
80
+ <title>Vm2Mage System Check</title>
81
+ <action>vm2mage/index</action>
82
+ </vm2mage>
83
+ </children>
84
+ </tools>
85
+ </children>
86
+ </system>
87
+ </menu>
88
<acl>
89
<resources>
90
<admin>
117
</events>
118
</adminhtml>
119
120
+ <admin>
121
+ <routers>
122
+ <vm2mage>
123
+ <use>admin</use>
124
+ <args>
125
+ <module>Yireo_Vm2Mage</module>
126
+ <frontName>vm2mage</frontName>
127
+ </args>
128
+ </vm2mage>
129
+ </routers>
130
+ </admin>
131
+
132
</config>
app/code/community/Yireo/Vm2Mage/sql/vm2mage_setup/mysql4-install-0.5.4.php CHANGED
@@ -4,8 +4,8 @@
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
- * @copyright Copyright 2009
8
- * @license Yireo EULA (www.yireo.com)
9
* @link http://www.yireo.com
10
*/
11
4
*
5
* @author Yireo
6
* @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
* @link http://www.yireo.com
10
*/
11
app/design/adminhtml/default/default/template/vm2mage/check.phtml ADDED
@@ -0,0 +1,47 @@
1
+ <?php
2
+ /**
3
+ * Vm2Mage
4
+ *
5
+ * @author Yireo
6
+ * @package Vm2Mage
7
+ * @copyright Copyright 2011
8
+ * @license Open Source License
9
+ * @link http://www.yireo.com
10
+ */
11
+ ?>
12
+
13
+ <div class="content-header">
14
+ <table cellspacing="0">
15
+ <tr>
16
+ <td style="width:100%;"><h3 class="icon-head head-tag"><?php echo $this->getHeader('System Check'); ?></h3></td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+
21
+ <?php foreach($this->getChecks() as $group => $checks) { ?>
22
+ <?php if($group == 'conf') $title = 'Magento Configuration'; ?>
23
+ <?php if($group == 'system') $title = 'Hosting Requirements'; ?>
24
+ <div class="entry-edit">
25
+ <div class="entry-edit-head">
26
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__($title); ?></h4>
27
+ </div>
28
+
29
+ <div class="fieldset ">
30
+ <table cellspacing="5" class="form-list">
31
+ <?php foreach($checks as $check) { ?>
32
+ <tr>
33
+ <td width="150"><strong><?php echo $check['check']; ?></strong></td>
34
+ <td width="50"><img src="<?php echo $this->getSkinUrl('images/vm2mage/check-'.$check['status'].'.png'); ?>" title="<?php echo $check['status']; ?>" alt="<?php echo $check['status']; ?>" /></td>
35
+ <td><?php echo $check['description']; ?></td>
36
+ </tr>
37
+ <?php } ?>
38
+ </table>
39
+ </div>
40
+ </div>
41
+ <?php } ?>
42
+
43
+ <strong>Legend:</strong><br/>
44
+ <img src="<?php echo $this->getSkinUrl('images/vm2mage/check-ok.png'); ?>" />&nbsp;<?php echo $this->__('Everything is ok'); ?><br/>
45
+ <img src="<?php echo $this->getSkinUrl('images/vm2mage/check-warning.png'); ?>" />&nbsp;<?php echo $this->__('There might be something wrong, so be warned'); ?><br/>
46
+ <img src="<?php echo $this->getSkinUrl('images/vm2mage/check-error.png'); ?>" />&nbsp;<?php echo $this->__('Something is preventing Vm2Mage from functioning correctly'); ?><br/>
47
+
package.xml CHANGED
@@ -1,18 +1,120 @@
1
- <?xml version="1.0"?>
2
<package>
3
<name>Yireo_Vm2Mage</name>
4
- <version>0.7.136</version>
5
<stability>stable</stability>
6
- <license uri="http://www.yireo.com/">Open Source License</license>
7
<channel>community</channel>
8
- <extends/>
9
- <summary>This module migrates VirtueMart data to Magento</summary>
10
- <description>This module migrates VrtueMart data to Magento</description>
11
<notes>See www.yireo.com/software for details</notes>
12
- <authors><author><name>Yireo</name><user>auto-converted</user><email>info@yireo.com</email></author></authors>
13
- <date>2011-04-14</date>
14
- <time>10:38:57</time>
15
- <contents><target name="magecommunity"><dir name="Zend"><dir name="XmlRpc"><file name="Server.php" hash="fb8e68c02df4556c45003b14816287c7"/></dir></dir><dir name="Yireo"><dir name="Vm2Mage"><dir name="etc"><file name="api.xml" hash="d1d23d2c80edc6b64df14329fb186506"/><file name="config.xml" hash="50b7efbcf50b35c019f34ef1c5bacf8e"/></dir><dir name="Helper"><file name="Attribute.php" hash="efbd18e2ffad812ba85202ccb7e1fdf2"/><file name="Category.php" hash="59263dbd97c8ddf69eca20b98bd286d1"/><file name="Data.php" hash="49982fdb521df8d1cebf4d868ca39437"/><file name="Image.php" hash="fd6a3f6cb9a71ca4309645e51bed78d3"/><file name="Price.php" hash="b645a4e621d79e804bcd1169d47594a3"/><file name="Product.php" hash="1d5c0075b64503157e31f0354e1e28db"/></dir><dir name="sql"><dir name="vm2mage_setup"><file name="mysql4-install-0.5.4.php" hash="02c00acc4fc4567bbabbddc79a5be9ad"/></dir></dir><dir name="Model"><dir name="Attribute"><file name="Api.php" hash="faf5b9e02be7743feef6028dd8bf1ddc"/></dir><dir name="Category"><file name="Api.php" hash="5d190343c895b8c36d98d6d71365d20a"/></dir><dir name="Order"><file name="Api.php" hash="d54dc82c88a7f38ed41c31a0f5e6ec7a"/></dir><dir name="Product"><file name="Api.php" hash="5aa166276d5adbdada769f4520b3e248"/></dir><dir name="User"><file name="Api.php" hash="8db7b072fd2c8769db7a295bfa5dafc2"/></dir><dir name="Widget"><file name="Api.php" hash="2101759679bc325e0ad911e1de2faa32"/></dir><file name="Observer.php" hash="562596697b3757b1cdacf7b748cdb3ba"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yireo_Vm2Mage.xml" hash="bee76713ff8df9db330a8385b2465041"/></dir></target></contents>
16
<compatible/>
17
- <dependencies/>
18
</package>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
<package>
3
<name>Yireo_Vm2Mage</name>
4
+ <version>0.7.196</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>2011-11-15</date>
12
+ <time>00:00:01</time>
13
+ <authors>
14
+ <author>
15
+ <name>Yireo</name>
16
+ <user>yireo</user>
17
+ <email>info@yireo.com</email>
18
+ </author>
19
+ </authors>
20
+
21
+ <contents>
22
+ <target name="mageskin">
23
+ <dir name="adminhtml">
24
+ <dir name="default">
25
+ <dir name="default">
26
+ <dir name="images">
27
+ <dir name="vm2mage">
28
+ <file name="check-ok.png" />
29
+ <file name="check-warning.png" />
30
+ <file name="check-error.png" />
31
+ </dir>
32
+ </dir>
33
+ </dir>
34
+ </dir>
35
+ </dir>
36
+ </target>
37
+ <target name="magedesign">
38
+ <dir name="adminhtml">
39
+ <dir name="default">
40
+ <dir name="default">
41
+ <dir name="template">
42
+ <dir name="vm2mage">
43
+ <file name="check.phtml" />
44
+ </dir>
45
+ </dir>
46
+ </dir>
47
+ </dir>
48
+ </dir>
49
+ </target>
50
+ <target name="magecommunity">
51
+ <dir name="Zend">
52
+ <dir name="XmlRpc">
53
+ <file name="Server.php" />
54
+ </dir>
55
+ </dir>
56
+ <dir name="Yireo">
57
+ <dir name="Vm2Mage">
58
+ <dir name="Block">
59
+ <file name="Check.php" />
60
+ </dir>
61
+ <dir name="controllers">
62
+ <file name="IndexController.php" />
63
+ </dir>
64
+ <dir name="etc">
65
+ <file name="api.xml" />
66
+ <file name="config.xml" />
67
+ </dir>
68
+ <dir name="Helper">
69
+ <file name="Attribute.php" />
70
+ <file name="Category.php" />
71
+ <file name="Data.php" />
72
+ <file name="Image.php" />
73
+ <file name="Price.php" />
74
+ <file name="Product.php" />
75
+ </dir>
76
+ <dir name="sql">
77
+ <dir name="vm2mage_setup">
78
+ <file name="mysql4-install-0.5.4.php" />
79
+ </dir>
80
+ </dir>
81
+ <dir name="Model">
82
+ <file name="Observer.php" />
83
+ <dir name="Attribute">
84
+ <file name="Api.php" />
85
+ </dir>
86
+ <dir name="Category">
87
+ <file name="Api.php" />
88
+ </dir>
89
+ <dir name="Order">
90
+ <file name="Api.php" />
91
+ </dir>
92
+ <dir name="Product">
93
+ <file name="Api.php" />
94
+ </dir>
95
+ <dir name="User">
96
+ <file name="Api.php" />
97
+ </dir>
98
+ <dir name="Widget">
99
+ <file name="Api.php" />
100
+ </dir>
101
+ </dir>
102
+ </dir>
103
+ </dir>
104
+ </target>
105
+ <target name="mageetc">
106
+ <dir name="modules">
107
+ <file name="Yireo_Vm2Mage.xml" />
108
+ </dir>
109
+ </target>
110
+ </contents>
111
<compatible/>
112
+ <dependencies>
113
+ <required>
114
+ <php>
115
+ <min>5.2.8</min>
116
+ <max>6.0.0</max>
117
+ </php>
118
+ </required>
119
+ </dependencies>
120
</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