Version Notes
No notes
Download this release
Release Info
| Developer | Yireo |
| Extension | Yireo_Vm2Mage |
| Version | 0.10.9 |
| Comparing to | |
| See all releases | |
Code changes from version 0.10.5 to 0.10.9
- app/code/community/Yireo/Vm2Mage/Block/Check.php +54 -0
- app/code/community/Yireo/Vm2Mage/Helper/Image.php +35 -9
- app/code/community/Yireo/Vm2Mage/Helper/Product.php +47 -4
- app/code/community/Yireo/Vm2Mage/Helper/Product.php.old +0 -75
- app/code/community/Yireo/Vm2Mage/Model/Attribute/Api.php +1 -1
- app/code/community/Yireo/Vm2Mage/Model/Product/Api.php +69 -22
- app/code/community/Yireo/Vm2Mage/Model/User/Api.php +32 -21
- app/code/community/Yireo/Vm2Mage/controllers/IndexController.php +59 -0
- app/code/community/Yireo/Vm2Mage/etc/config.old +0 -132
- app/code/community/Yireo/Vm2Mage/etc/config.xml +3 -2
- app/code/community/Yireo/Vm2Mage/etc/system.xml +11 -1
- app/design/adminhtml/default/default/template/vm2mage/check.phtml +7 -1
- package.xml +1 -1
app/code/community/Yireo/Vm2Mage/Block/Check.php
CHANGED
|
@@ -182,4 +182,58 @@ class Yireo_Vm2Mage_Block_Check extends Mage_Core_Block_Template
|
|
| 182 |
|
| 183 |
return $this->system_checks;
|
| 184 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 182 |
|
| 183 |
return $this->system_checks;
|
| 184 |
}
|
| 185 |
+
|
| 186 |
+
/*
|
| 187 |
+
* Helper to return the URL for deleting all categories
|
| 188 |
+
*
|
| 189 |
+
* @access public
|
| 190 |
+
* @param null
|
| 191 |
+
* @return string
|
| 192 |
+
*/
|
| 193 |
+
public function getDeleteCategoriesUrl()
|
| 194 |
+
{
|
| 195 |
+
return Mage::getModel('adminhtml/url')->getUrl('vm2mage/index/deleteCategories');
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/*
|
| 199 |
+
* Helper to return the URL for deleting all products
|
| 200 |
+
*
|
| 201 |
+
* @access public
|
| 202 |
+
* @param null
|
| 203 |
+
* @return string
|
| 204 |
+
*/
|
| 205 |
+
public function getDeleteProductsUrl()
|
| 206 |
+
{
|
| 207 |
+
return Mage::getModel('adminhtml/url')->getUrl('vm2mage/index/deleteProducts');
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Render block HTML
|
| 212 |
+
*
|
| 213 |
+
* @access protected
|
| 214 |
+
* @param null
|
| 215 |
+
* @return mixed
|
| 216 |
+
*/
|
| 217 |
+
protected function _toHtml()
|
| 218 |
+
{
|
| 219 |
+
$this->setChild('products_delete_button',
|
| 220 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
| 221 |
+
->setData(array(
|
| 222 |
+
'label' => Mage::helper('catalog')->__('Delete All Products'),
|
| 223 |
+
'onclick' => 'window.location = \''.$this->getDeleteProductsUrl().'\'',
|
| 224 |
+
'class' => 'delete'
|
| 225 |
+
))
|
| 226 |
+
);
|
| 227 |
+
|
| 228 |
+
$this->setChild('categories_delete_button',
|
| 229 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
| 230 |
+
->setData(array(
|
| 231 |
+
'label' => Mage::helper('catalog')->__('Delete All Categories'),
|
| 232 |
+
'onclick' => 'window.location = \''.$this->getDeleteCategoriesUrl().'\'',
|
| 233 |
+
'class' => 'delete'
|
| 234 |
+
))
|
| 235 |
+
);
|
| 236 |
+
|
| 237 |
+
return parent::_toHtml();
|
| 238 |
+
}
|
| 239 |
}
|
app/code/community/Yireo/Vm2Mage/Helper/Image.php
CHANGED
|
@@ -59,11 +59,11 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 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()
|
|
|
|
| 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) {
|
|
@@ -73,9 +73,11 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 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;
|
|
@@ -92,14 +94,19 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 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;
|
|
@@ -129,7 +136,8 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 129 |
}
|
| 130 |
|
| 131 |
// Create a temporary file
|
| 132 |
-
$
|
|
|
|
| 133 |
|
| 134 |
// Get the remote image
|
| 135 |
$tmp_content = self::getRemoteContent($url);
|
|
@@ -142,6 +150,12 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 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-download does not match MD5', $tmp_file);
|
|
@@ -149,11 +163,11 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 149 |
}
|
| 150 |
|
| 151 |
// Add the image to the gallery
|
| 152 |
-
$product = $product->addImageToMediaGallery($tmp_file, $types,
|
| 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
|
|
@@ -195,21 +209,33 @@ class Yireo_Vm2Mage_Helper_Image extends Yireo_Vm2Mage_Helper_Data
|
|
| 195 |
return false;
|
| 196 |
}
|
| 197 |
|
| 198 |
-
//
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
// Get the remote image and write it to the temporary file
|
|
|
|
|
|
|
| 202 |
if(@copy($file, $tmp_file) == false) {
|
| 203 |
Mage::helper('vm2mage')->debug('ERROR: Copy new image to image-folder failed', $base_dir);
|
| 204 |
return false;
|
| 205 |
}
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
// Add the image to the gallery
|
| 208 |
-
|
|
|
|
| 209 |
|
| 210 |
// Clean temporary file if needed
|
| 211 |
if(file_exists($tmp_file)) {
|
| 212 |
-
unlink($tmp_file);
|
| 213 |
}
|
| 214 |
|
| 215 |
// Return the changed product-object
|
| 59 |
|
| 60 |
// Renew images
|
| 61 |
if($renewImages) {
|
|
|
|
| 62 |
|
| 63 |
// Check whether the images are already there
|
| 64 |
$galleryImages = $product->getMediaGalleryImages();
|
| 65 |
+
if(is_object($galleryImages) && $galleryImages->count() > 0) {
|
| 66 |
+
Mage::helper('vm2mage')->debug('NOTICE: Removing existing 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) {
|
| 73 |
}
|
| 74 |
|
| 75 |
// Loop through the images and create them
|
| 76 |
+
$migratedFiles = array();
|
| 77 |
if(is_array($images) && !empty($images)) {
|
| 78 |
foreach($images as $image) {
|
| 79 |
|
| 80 |
+
if(in_array($image['md5sum'], $migratedFiles)) continue;
|
| 81 |
if(empty($image['label'])) $image['label'] = $product->getName();
|
| 82 |
if(empty($image['file'])) $image['file'] = null;
|
| 83 |
if(empty($image['md5sum'])) $image['md5sum'] = null;
|
| 94 |
$result = self::addLocalImage($product, $image['file'], $image['label'], $imageTypes);
|
| 95 |
if($result != false) {
|
| 96 |
$product = $result;
|
| 97 |
+
$migratedFiles[] = $image['md5sum'];
|
| 98 |
} else {
|
| 99 |
$result = self::addRemoteImage($product, $image['url'], $image['md5sum'], $image['type'], $image['label'], $imageTypes);
|
| 100 |
if($result != false) {
|
| 101 |
$product = $result;
|
| 102 |
+
$migratedFiles[] = $image['md5sum'];
|
| 103 |
}
|
| 104 |
}
|
| 105 |
}
|
| 106 |
}
|
| 107 |
+
|
| 108 |
+
// Save the product
|
| 109 |
+
$product->save();
|
| 110 |
}
|
| 111 |
|
| 112 |
return $product;
|
| 136 |
}
|
| 137 |
|
| 138 |
// Create a temporary file
|
| 139 |
+
$tmp_basename = md5($product->getId().$url).'.'.preg_replace('/(.*)\.(gif|jpg|jpeg|png)/', '\2', strtolower($url));
|
| 140 |
+
$tmp_file = $base_dir.DS.$tmp_basename;
|
| 141 |
|
| 142 |
// Get the remote image
|
| 143 |
$tmp_content = self::getRemoteContent($url);
|
| 150 |
// Write it to the temporary file
|
| 151 |
file_put_contents($tmp_file, $tmp_content);
|
| 152 |
|
| 153 |
+
// Check whether the new file exists
|
| 154 |
+
if(file_exists($tmp_file) == false) {
|
| 155 |
+
Mage::helper('vm2mage')->debug('ERROR: Copy new image to image-folder succeeded, but still not image', $tmp_file);
|
| 156 |
+
return false;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
// Check the MD5 sum of this file
|
| 160 |
if(!empty($md5sum) && md5_file($tmp_file) != $md5sum) {
|
| 161 |
Mage::helper('vm2mage')->debug('ERROR: image-download does not match MD5', $tmp_file);
|
| 163 |
}
|
| 164 |
|
| 165 |
// Add the image to the gallery
|
| 166 |
+
$product = $product->addImageToMediaGallery($tmp_file, $types, false, false);
|
| 167 |
|
| 168 |
// Clean temporary file if needed
|
| 169 |
if(file_exists($tmp_file)) {
|
| 170 |
+
@unlink($tmp_file);
|
| 171 |
}
|
| 172 |
|
| 173 |
// Return the changed product-object
|
| 209 |
return false;
|
| 210 |
}
|
| 211 |
|
| 212 |
+
// Check for empty images
|
| 213 |
+
if(filesize($file) == 0) {
|
| 214 |
+
Mage::helper('vm2mage')->debug('ERROR: Source-image has a size of 0', $file);
|
| 215 |
+
return false;
|
| 216 |
+
}
|
| 217 |
|
| 218 |
// Get the remote image and write it to the temporary file
|
| 219 |
+
$tmp_basename = md5($product->getId().$file).'.'.preg_replace('/(.*)\.(gif|jpg|jpeg|png)/', '\2', strtolower($file));
|
| 220 |
+
$tmp_file = $base_dir.DS.$tmp_basename;
|
| 221 |
if(@copy($file, $tmp_file) == false) {
|
| 222 |
Mage::helper('vm2mage')->debug('ERROR: Copy new image to image-folder failed', $base_dir);
|
| 223 |
return false;
|
| 224 |
}
|
| 225 |
|
| 226 |
+
// Check whether the new file exists
|
| 227 |
+
if(file_exists($tmp_file) == false) {
|
| 228 |
+
Mage::helper('vm2mage')->debug('ERROR: Copy new image to image-folder succeeded, but still not image', $tmp_file);
|
| 229 |
+
return false;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
// Add the image to the gallery
|
| 233 |
+
Mage::helper('vm2mage')->debug('NOTICE: ['.$product->getSku().'] Adding new image', $tmp_file);
|
| 234 |
+
$product = $product->addImageToMediaGallery($tmp_file, $types, false, false);
|
| 235 |
|
| 236 |
// Clean temporary file if needed
|
| 237 |
if(file_exists($tmp_file)) {
|
| 238 |
+
@unlink($tmp_file);
|
| 239 |
}
|
| 240 |
|
| 241 |
// Return the changed product-object
|
app/code/community/Yireo/Vm2Mage/Helper/Product.php
CHANGED
|
@@ -26,10 +26,13 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
|
|
| 26 |
$childIds = array();
|
| 27 |
foreach($children as $child) {
|
| 28 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
Mage::getModel('vm2mage/product_api')->migrate($child);
|
| 31 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 32 |
-
}
|
| 33 |
$childIds[] = $childId;
|
| 34 |
}
|
| 35 |
|
|
@@ -103,10 +106,13 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
|
|
| 103 |
$childIds = array();
|
| 104 |
foreach($children as $child) {
|
| 105 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
Mage::getModel('vm2mage/product_api')->migrate($child);
|
| 108 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 109 |
-
}
|
| 110 |
$childIds[] = $childId;
|
| 111 |
}
|
| 112 |
|
|
@@ -150,4 +156,41 @@ class Yireo_Vm2Mage_Helper_Product extends Yireo_Vm2Mage_Helper_Data
|
|
| 150 |
|
| 151 |
return $product;
|
| 152 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
}
|
| 26 |
$childIds = array();
|
| 27 |
foreach($children as $child) {
|
| 28 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 29 |
+
|
| 30 |
+
// @todo: Should we re-migrate the product or not?
|
| 31 |
+
//if(empty($childId)) {
|
| 32 |
+
if(empty($child['price']['product_price'])) $child['price']['product_price'] = $product->getPrice();
|
| 33 |
Mage::getModel('vm2mage/product_api')->migrate($child);
|
| 34 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 35 |
+
//}
|
| 36 |
$childIds[] = $childId;
|
| 37 |
}
|
| 38 |
|
| 106 |
$childIds = array();
|
| 107 |
foreach($children as $child) {
|
| 108 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 109 |
+
|
| 110 |
+
// @todo: Should we re-migrate the product or not?
|
| 111 |
+
//if(empty($childId)) {
|
| 112 |
+
if(empty($child['price']['product_price'])) $child['price']['product_price'] = $product->getPrice();
|
| 113 |
Mage::getModel('vm2mage/product_api')->migrate($child);
|
| 114 |
$childId = Mage::getModel('catalog/product')->getIdBySku($child['sku']);
|
| 115 |
+
//}
|
| 116 |
$childIds[] = $childId;
|
| 117 |
}
|
| 118 |
|
| 156 |
|
| 157 |
return $product;
|
| 158 |
}
|
| 159 |
+
|
| 160 |
+
/*
|
| 161 |
+
* Helper-method to add custom options to a product
|
| 162 |
+
*
|
| 163 |
+
* @param Mage_Catalog_Model_Product $product
|
| 164 |
+
* @param string $name
|
| 165 |
+
* @param array $values
|
| 166 |
+
* @return $product
|
| 167 |
+
*/
|
| 168 |
+
public function addCustomOptionsToProduct($product, $name, $values)
|
| 169 |
+
{
|
| 170 |
+
$option = array(
|
| 171 |
+
'title' => $name,
|
| 172 |
+
'type' => 'drop_down',
|
| 173 |
+
'is_require' => 1,
|
| 174 |
+
'sort_order' => 0,
|
| 175 |
+
'values' => array(),
|
| 176 |
+
);
|
| 177 |
+
|
| 178 |
+
foreach($values as $value) {
|
| 179 |
+
if(!isset($value['price'])) $value['price'] = null;
|
| 180 |
+
$option['values'][] = array(
|
| 181 |
+
'title' => $value['label'],
|
| 182 |
+
'price' => $value['price'],
|
| 183 |
+
'price_type' => 'fixed',
|
| 184 |
+
'sku' => '',
|
| 185 |
+
'sort_order' => '1'
|
| 186 |
+
);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
if(!$product->getOptionsReadonly()) {
|
| 190 |
+
$product->setProductOptions(array($option));
|
| 191 |
+
$product->setCanSaveCustomOptions(true);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
return $product;
|
| 195 |
+
}
|
| 196 |
}
|
app/code/community/Yireo/Vm2Mage/Helper/Product.php.old
DELETED
|
@@ -1,75 +0,0 @@
|
|
| 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
|
@@ -25,7 +25,7 @@ class Yireo_Vm2Mage_Model_Attribute_Api extends Mage_Api_Model_Resource_Abstract
|
|
| 25 |
}
|
| 26 |
|
| 27 |
// Debugging
|
| 28 |
-
Mage::helper('vm2mage')->debug('VirtueMart attribute', $data);
|
| 29 |
|
| 30 |
// Flags
|
| 31 |
$isNew = false;
|
| 25 |
}
|
| 26 |
|
| 27 |
// Debugging
|
| 28 |
+
//Mage::helper('vm2mage')->debug('VirtueMart attribute', $data);
|
| 29 |
|
| 30 |
// Flags
|
| 31 |
$isNew = false;
|
app/code/community/Yireo/Vm2Mage/Model/Product/Api.php
CHANGED
|
@@ -30,10 +30,10 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 30 |
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
|
| 31 |
|
| 32 |
// Determine the product-type
|
| 33 |
-
if($data['has_children'] > 0) {
|
| 34 |
-
|
|
|
|
| 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 |
}
|
|
@@ -76,10 +76,9 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 76 |
$data['status'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
|
| 77 |
}
|
| 78 |
|
| 79 |
-
// Make sure
|
| 80 |
-
if(empty($data['short_description']))
|
| 81 |
-
|
| 82 |
-
}
|
| 83 |
|
| 84 |
// Set common attributes
|
| 85 |
$product->setData($product->getData())
|
|
@@ -92,6 +91,11 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 92 |
->setTaxClassId($taxId)
|
| 93 |
;
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
// Set weight
|
| 96 |
if(isset($data['weight'])) {
|
| 97 |
$product->setWeight($data['weight']);
|
|
@@ -121,6 +125,24 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 121 |
$product->setMetaTitle($product->getTitle());
|
| 122 |
}
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
// Set the custom attributes
|
| 125 |
if(isset($data['attributes'])) {
|
| 126 |
foreach($data['attributes'] as $name => $value) {
|
|
@@ -149,6 +171,32 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 149 |
$product->setSpecialToDate($data['special_price']['end_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) {
|
|
@@ -188,15 +236,6 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 188 |
$product->setIsMassupdate(true);
|
| 189 |
$product->setExcludeUrlRewrite(true);
|
| 190 |
|
| 191 |
-
// Get the remote images
|
| 192 |
-
if(isset($data['images'])) {
|
| 193 |
-
try {
|
| 194 |
-
$product = Mage::helper('vm2mage/image')->addImages($product, $data['images']);
|
| 195 |
-
} catch(Exception $e) {
|
| 196 |
-
return array(0, $e->getMessage());
|
| 197 |
-
}
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
// Add the related products
|
| 201 |
if(!empty($data['related_products'])) {
|
| 202 |
try {
|
|
@@ -219,12 +258,8 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 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 |
-
}
|
| 223 |
-
|
| 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)) {
|
|
@@ -232,6 +267,18 @@ class Yireo_Vm2Mage_Model_Product_Api extends Mage_Catalog_Model_Product_Api
|
|
| 232 |
}
|
| 233 |
}
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
// Return true by default
|
| 236 |
if($isNew) {
|
| 237 |
return array(1, "Created new product ".$product->getName()." [".$product->getId()."]", $data['id']);
|
| 30 |
//Mage::helper('vm2mage')->debug('VirtueMart product', $data);
|
| 31 |
|
| 32 |
// Determine the product-type
|
| 33 |
+
if($data['has_children'] > 0 && !empty($data['attributes_sku'])) {
|
| 34 |
+
$typeId = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE;
|
| 35 |
+
} elseif($data['has_children'] > 0) {
|
| 36 |
$typeId = Mage_Catalog_Model_Product_Type::TYPE_GROUPED;
|
|
|
|
| 37 |
} else {
|
| 38 |
$typeId = Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
|
| 39 |
}
|
| 76 |
$data['status'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
|
| 77 |
}
|
| 78 |
|
| 79 |
+
// Make sure descriptions match
|
| 80 |
+
if(empty($data['short_description'])) $data['short_description'] = $data['name'];
|
| 81 |
+
if(empty($data['description'])) $data['description'] = $data['short_description'];
|
|
|
|
| 82 |
|
| 83 |
// Set common attributes
|
| 84 |
$product->setData($product->getData())
|
| 91 |
->setTaxClassId($taxId)
|
| 92 |
;
|
| 93 |
|
| 94 |
+
// Set for single store mode
|
| 95 |
+
if (Mage::app()->isSingleStoreMode()) {
|
| 96 |
+
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
// Set weight
|
| 100 |
if(isset($data['weight'])) {
|
| 101 |
$product->setWeight($data['weight']);
|
| 125 |
$product->setMetaTitle($product->getTitle());
|
| 126 |
}
|
| 127 |
|
| 128 |
+
// Set the Custom Options
|
| 129 |
+
if(isset($data['attribute'])) {
|
| 130 |
+
|
| 131 |
+
// Remove all current options
|
| 132 |
+
$options = $product->getOptions();
|
| 133 |
+
if(!empty($options)) {
|
| 134 |
+
foreach($options as $option) {
|
| 135 |
+
$option->delete();
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// Add the custom options again
|
| 140 |
+
foreach($data['attribute'] as $attribute) {
|
| 141 |
+
$product = Mage::helper('vm2mage/product')->addCustomOptionsToProduct($product, $attribute['name'], $attribute['values']);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
// Set the custom attributes
|
| 147 |
if(isset($data['attributes'])) {
|
| 148 |
foreach($data['attributes'] as $name => $value) {
|
| 171 |
$product->setSpecialToDate($data['special_price']['end_date']);
|
| 172 |
}
|
| 173 |
|
| 174 |
+
// Set the tier pricing
|
| 175 |
+
if(!empty($data['all_prices']) && count($data['all_prices']) > 1) {
|
| 176 |
+
$tierPrices = array();
|
| 177 |
+
foreach($data['all_prices'] as $price) {
|
| 178 |
+
|
| 179 |
+
if($price['price_quantity_start'] < 1) continue;
|
| 180 |
+
if($price['price_quantity_end'] < 1) continue;
|
| 181 |
+
|
| 182 |
+
$customerGroup = Mage_Customer_Model_Group::CUST_GROUP_ALL;
|
| 183 |
+
$customerAllGroups = 1;
|
| 184 |
+
// @todo: Use a mapping for customer_groups
|
| 185 |
+
//if($price['shopper_group_default'] == 0) {
|
| 186 |
+
// $customerAllGroups = 1;
|
| 187 |
+
//}
|
| 188 |
+
|
| 189 |
+
$tierPrices[] = array(
|
| 190 |
+
'website_id' => 0,
|
| 191 |
+
'all_groups' => $customerAllGroups,
|
| 192 |
+
'cust_group' => $customerGroup,
|
| 193 |
+
'price_qty' => $price['price_quantity_start'],
|
| 194 |
+
'price' => $price['product_price'],
|
| 195 |
+
);
|
| 196 |
+
}
|
| 197 |
+
$product->setTierPrice($tierPrices);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
// Handle the stock
|
| 201 |
if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) $data['in_stock'] = null;
|
| 202 |
if(!empty($data['in_stock']) && $data['in_stock'] > 0) {
|
| 236 |
$product->setIsMassupdate(true);
|
| 237 |
$product->setExcludeUrlRewrite(true);
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
// Add the related products
|
| 240 |
if(!empty($data['related_products'])) {
|
| 241 |
try {
|
| 258 |
if($data['has_children'] > 0) {
|
| 259 |
if($typeId == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
|
| 260 |
$rs = Mage::helper('vm2mage/product')->addChildrenToGrouped($data['children'], $product);
|
| 261 |
+
} elseif($typeId == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
|
| 262 |
+
$rs = Mage::helper('vm2mage/product')->addChildrenToConfigurable($data['children'], $data['attributes_sku'], $product);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
if(!empty($rs)) {
|
| 267 |
}
|
| 268 |
}
|
| 269 |
|
| 270 |
+
// Get the remote images
|
| 271 |
+
if(isset($data['images'])) {
|
| 272 |
+
try {
|
| 273 |
+
$product = Mage::helper('vm2mage/image')->addImages($product, $data['images']);
|
| 274 |
+
} catch(Exception $e) {
|
| 275 |
+
return array(0, $e->getMessage());
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Apply rules
|
| 280 |
+
Mage::getModel('catalogrule/rule')->applyAllRulesToProduct($product->getId());
|
| 281 |
+
|
| 282 |
// Return true by default
|
| 283 |
if($isNew) {
|
| 284 |
return array(1, "Created new product ".$product->getName()." [".$product->getId()."]", $data['id']);
|
app/code/community/Yireo/Vm2Mage/Model/User/Api.php
CHANGED
|
@@ -19,6 +19,9 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 19 |
*/
|
| 20 |
public function migrate($data = null)
|
| 21 |
{
|
|
|
|
|
|
|
|
|
|
| 22 |
// Check for empty data
|
| 23 |
if(!is_array($data)) {
|
| 24 |
return array(0, "Data is not an array");
|
|
@@ -95,24 +98,28 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 95 |
$customer->setPasswordHash($data['password']);
|
| 96 |
}
|
| 97 |
|
| 98 |
-
//
|
| 99 |
-
|
| 100 |
-
$customer->save();
|
| 101 |
-
} catch(Exception $e) {
|
| 102 |
-
return array(0, $e->getMessage());
|
| 103 |
-
}
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
| 109 |
}
|
| 110 |
-
} else {
|
| 111 |
-
$rt = $this->saveAddress($customer, $data);
|
| 112 |
-
}
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
// Save the orders
|
|
@@ -184,8 +191,11 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 184 |
|
| 185 |
// Load the region
|
| 186 |
$region = null;
|
| 187 |
-
if(empty($data['
|
| 188 |
-
if(
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
// Set basic values
|
| 191 |
$address
|
|
@@ -206,7 +216,6 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 206 |
'fax' => 'fax',
|
| 207 |
'city' => 'city',
|
| 208 |
'zip' => 'postcode',
|
| 209 |
-
'state' => 'region',
|
| 210 |
'country' => 'country',
|
| 211 |
'taxvat' => 'vat_id',
|
| 212 |
);
|
|
@@ -224,6 +233,7 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 224 |
// Set the region
|
| 225 |
if(!empty($region)) {
|
| 226 |
$address->setRegionId($region->getId());
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
// Set the customer if needed
|
|
@@ -351,6 +361,7 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 351 |
$model->setOrderId($order['order_id']);
|
| 352 |
$model->setOrderNumber($order['order_number']);
|
| 353 |
$model->setOrderTotal($order['order_total']);
|
|
|
|
| 354 |
$model->setOrderCurrency($order_currency);
|
| 355 |
$model->setOrderTax($order['order_tax']);
|
| 356 |
$model->setOrderTaxDetails($order['order_tax_details']);
|
|
@@ -360,11 +371,11 @@ class Yireo_Vm2Mage_Model_User_Api extends Mage_Customer_Model_Customer_Api
|
|
| 360 |
$model->setOrderDiscount($order['order_discount']);
|
| 361 |
$model->setOrderStatusName($order['order_status_name']);
|
| 362 |
$model->setOrderStatus($order['order_status']);
|
| 363 |
-
$model->setCreateDate($order['
|
| 364 |
-
$model->setModifyDate($order['
|
| 365 |
-
$model->setShipMethodId($order['ship_method_id']);
|
| 366 |
$model->setCustomerNote($order['customer_note']);
|
| 367 |
$model->setPaymentMethod($order['payment_method']);
|
|
|
|
| 368 |
$model->save(); // skipped: order_id, vendor_id, user_info_id, ip-address
|
| 369 |
|
| 370 |
// Loop through the order-items and save them as well
|
| 19 |
*/
|
| 20 |
public function migrate($data = null)
|
| 21 |
{
|
| 22 |
+
// Option to renew customers or not
|
| 23 |
+
$renewCustomers = (bool)Mage::getStoreConfig('vm2mage/settings/renew_customers');
|
| 24 |
+
|
| 25 |
// Check for empty data
|
| 26 |
if(!is_array($data)) {
|
| 27 |
return array(0, "Data is not an array");
|
| 98 |
$customer->setPasswordHash($data['password']);
|
| 99 |
}
|
| 100 |
|
| 101 |
+
// Only save if allowed
|
| 102 |
+
if($customerId < 1 || $renewCustomers == true) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
+
// Try to safe this customer to the database
|
| 105 |
+
try {
|
| 106 |
+
$customer->save();
|
| 107 |
+
} catch(Exception $e) {
|
| 108 |
+
return array(0, $e->getMessage());
|
| 109 |
}
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
+
// Save the address
|
| 112 |
+
if(isset($data['addresses']) && !empty($data['addresses'])) {
|
| 113 |
+
foreach($data['addresses'] as $address) {
|
| 114 |
+
$rt = $this->saveAddress($customer, $address, $data);
|
| 115 |
+
}
|
| 116 |
+
} else {
|
| 117 |
+
$rt = $this->saveAddress($customer, $data);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
if(!empty($rt)) {
|
| 121 |
+
return $rt;
|
| 122 |
+
}
|
| 123 |
}
|
| 124 |
|
| 125 |
// Save the orders
|
| 191 |
|
| 192 |
// Load the region
|
| 193 |
$region = null;
|
| 194 |
+
if(empty($data['state']) && !empty($customerData['state'])) $data['state'] = $customerData['state'];
|
| 195 |
+
if(empty($data['state']) && !empty($customerData['region'])) $data['state'] = $customerData['region'];
|
| 196 |
+
if(!empty($data['state'])) $region = Mage::getModel('directory/region')->loadByCode($data['state'], $country->getId());
|
| 197 |
+
Mage::log('isse: '.$data['state'].' / '.$country->getId());
|
| 198 |
+
Mage::log('sisse: '.$region->getId());
|
| 199 |
|
| 200 |
// Set basic values
|
| 201 |
$address
|
| 216 |
'fax' => 'fax',
|
| 217 |
'city' => 'city',
|
| 218 |
'zip' => 'postcode',
|
|
|
|
| 219 |
'country' => 'country',
|
| 220 |
'taxvat' => 'vat_id',
|
| 221 |
);
|
| 233 |
// Set the region
|
| 234 |
if(!empty($region)) {
|
| 235 |
$address->setRegionId($region->getId());
|
| 236 |
+
$address->setRegionName($region->getName());
|
| 237 |
}
|
| 238 |
|
| 239 |
// Set the customer if needed
|
| 361 |
$model->setOrderId($order['order_id']);
|
| 362 |
$model->setOrderNumber($order['order_number']);
|
| 363 |
$model->setOrderTotal($order['order_total']);
|
| 364 |
+
$model->setOrderSubtotal($order['order_subtotal']);
|
| 365 |
$model->setOrderCurrency($order_currency);
|
| 366 |
$model->setOrderTax($order['order_tax']);
|
| 367 |
$model->setOrderTaxDetails($order['order_tax_details']);
|
| 371 |
$model->setOrderDiscount($order['order_discount']);
|
| 372 |
$model->setOrderStatusName($order['order_status_name']);
|
| 373 |
$model->setOrderStatus($order['order_status']);
|
| 374 |
+
$model->setCreateDate($order['create_date']);
|
| 375 |
+
$model->setModifyDate($order['modify_date']);
|
|
|
|
| 376 |
$model->setCustomerNote($order['customer_note']);
|
| 377 |
$model->setPaymentMethod($order['payment_method']);
|
| 378 |
+
$model->setShipMethodId($order['shipment_method']);
|
| 379 |
$model->save(); // skipped: order_id, vendor_id, user_info_id, ip-address
|
| 380 |
|
| 381 |
// Loop through the order-items and save them as well
|
app/code/community/Yireo/Vm2Mage/controllers/IndexController.php
CHANGED
|
@@ -47,4 +47,63 @@ class Yireo_Vm2Mage_IndexController extends Mage_Adminhtml_Controller_Action
|
|
| 47 |
->_addContent($this->getLayout()->createBlock('vm2mage/check'))
|
| 48 |
->renderLayout();
|
| 49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 47 |
->_addContent($this->getLayout()->createBlock('vm2mage/check'))
|
| 48 |
->renderLayout();
|
| 49 |
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Delete all categories
|
| 53 |
+
*
|
| 54 |
+
* @access public
|
| 55 |
+
* @param null
|
| 56 |
+
* @return null
|
| 57 |
+
*/
|
| 58 |
+
public function deleteCategoriesAction()
|
| 59 |
+
{
|
| 60 |
+
Mage::getSingleton('index/indexer')->lockIndexer();
|
| 61 |
+
|
| 62 |
+
$categories = Mage::getModel('catalog/category')->getCollection();
|
| 63 |
+
foreach($categories as $category) {
|
| 64 |
+
if($category->getParentId() == 0) continue;
|
| 65 |
+
if($category->getLevel() <= 1) continue;
|
| 66 |
+
$category->delete();
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
$resource = Mage::getSingleton('core/resource');
|
| 70 |
+
$writeConnection = $resource->getConnection('core_write');
|
| 71 |
+
$tableName = $resource->getTableName('vm2mage_categories');
|
| 72 |
+
$query = 'TRUNCATE TABLE '.$tableName;
|
| 73 |
+
$writeConnection->query($query);
|
| 74 |
+
|
| 75 |
+
Mage::getSingleton('index/indexer')->unlockIndexer();
|
| 76 |
+
|
| 77 |
+
Mage::getModel('adminhtml/session')->addSuccess('Categories deleted');
|
| 78 |
+
$url = Mage::getModel('adminhtml/url')->getUrl('vm2mage/index/index');
|
| 79 |
+
$this->getResponse()->setRedirect($url);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Delete all products
|
| 84 |
+
*
|
| 85 |
+
* @access public
|
| 86 |
+
* @param null
|
| 87 |
+
* @return null
|
| 88 |
+
*/
|
| 89 |
+
public function deleteProductsAction()
|
| 90 |
+
{
|
| 91 |
+
Mage::getSingleton('index/indexer')->lockIndexer();
|
| 92 |
+
|
| 93 |
+
$products = Mage::getModel('catalog/product')->getCollection();
|
| 94 |
+
foreach($products as $product) {
|
| 95 |
+
$product->setIsMassupdate(true);
|
| 96 |
+
$product->setExcludeUrlRewrite(true);
|
| 97 |
+
$product->delete();
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
Mage::getSingleton('index/indexer')->unlockIndexer();
|
| 101 |
+
|
| 102 |
+
// @todo: Generate notice to reindex all indices
|
| 103 |
+
// @todo: Flush cache
|
| 104 |
+
|
| 105 |
+
Mage::getModel('adminhtml/session')->addSuccess('Products deleted');
|
| 106 |
+
$url = Mage::getModel('adminhtml/url')->getUrl('vm2mage/index/index');
|
| 107 |
+
$this->getResponse()->setRedirect($url);
|
| 108 |
+
}
|
| 109 |
}
|
app/code/community/Yireo/Vm2Mage/etc/config.old
DELETED
|
@@ -1,132 +0,0 @@
|
|
| 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
|
@@ -6,7 +6,7 @@
|
|
| 6 |
* @author Yireo
|
| 7 |
* @package Vm2Mage
|
| 8 |
* @copyright Copyright 2013
|
| 9 |
-
* @license
|
| 10 |
* @link http://www.yireo.com
|
| 11 |
*/
|
| 12 |
-->
|
|
@@ -14,7 +14,7 @@
|
|
| 14 |
|
| 15 |
<modules>
|
| 16 |
<Yireo_Vm2Mage>
|
| 17 |
-
<version>0.10.
|
| 18 |
</Yireo_Vm2Mage>
|
| 19 |
</modules>
|
| 20 |
|
|
@@ -140,6 +140,7 @@
|
|
| 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>
|
| 6 |
* @author Yireo
|
| 7 |
* @package Vm2Mage
|
| 8 |
* @copyright Copyright 2013
|
| 9 |
+
* @license Open Source License
|
| 10 |
* @link http://www.yireo.com
|
| 11 |
*/
|
| 12 |
-->
|
| 14 |
|
| 15 |
<modules>
|
| 16 |
<Yireo_Vm2Mage>
|
| 17 |
+
<version>0.10.9</version>
|
| 18 |
</Yireo_Vm2Mage>
|
| 19 |
</modules>
|
| 20 |
|
| 140 |
<debug_log>0</debug_log>
|
| 141 |
<local_images>1</local_images>
|
| 142 |
<renew_images>1</renew_images>
|
| 143 |
+
<renew_customers>1</renew_customers>
|
| 144 |
<delete_attributes>0</delete_attributes>
|
| 145 |
</settings>
|
| 146 |
</vm2mage>
|
app/code/community/Yireo/Vm2Mage/etc/system.xml
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
* @author Yireo
|
| 7 |
* @package Vm2Mage
|
| 8 |
* @copyright Copyright 2013
|
| 9 |
-
* @license
|
| 10 |
* @link http://www.yireo.com
|
| 11 |
*/
|
| 12 |
-->
|
|
@@ -59,6 +59,16 @@
|
|
| 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>
|
| 6 |
* @author Yireo
|
| 7 |
* @package Vm2Mage
|
| 8 |
* @copyright Copyright 2013
|
| 9 |
+
* @license Open Source License
|
| 10 |
* @link http://www.yireo.com
|
| 11 |
*/
|
| 12 |
-->
|
| 59 |
<show_in_store>1</show_in_store>
|
| 60 |
<comment>Delete old images and re-import new</comment>
|
| 61 |
</renew_images>
|
| 62 |
+
<renew_customers translate="label">
|
| 63 |
+
<label>Renew Customers</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>If disabled, customer-orders are still migrated</comment>
|
| 71 |
+
</renew_customers>
|
| 72 |
<delete_attributes translate="label">
|
| 73 |
<label>Delete Existing Attributes</label>
|
| 74 |
<frontend_type>select</frontend_type>
|
app/design/adminhtml/default/default/template/vm2mage/check.phtml
CHANGED
|
@@ -13,7 +13,13 @@
|
|
| 13 |
<div class="content-header">
|
| 14 |
<table cellspacing="0">
|
| 15 |
<tr>
|
| 16 |
-
<td style="width:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</tr>
|
| 18 |
</table>
|
| 19 |
</div>
|
| 13 |
<div class="content-header">
|
| 14 |
<table cellspacing="0">
|
| 15 |
<tr>
|
| 16 |
+
<td style="width:50%;">
|
| 17 |
+
<h3 class="icon-head head-tag"><?php echo $this->getHeader('System Check'); ?></h3>
|
| 18 |
+
</td>
|
| 19 |
+
<td class="formbuttons" align="right">
|
| 20 |
+
<?php echo $this->getChildHtml('categories_delete_button'); ?>
|
| 21 |
+
<?php echo $this->getChildHtml('products_delete_button'); ?>
|
| 22 |
+
</td>
|
| 23 |
</tr>
|
| 24 |
</table>
|
| 25 |
</div>
|
package.xml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
-
<package><name>Yireo_Vm2Mage</name><version>0.10.
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
+
<package><name>Yireo_Vm2Mage</name><version>0.10.9</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-12-27</date><time>1:32:50</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="323ec99b3f63cad12547d197cc31564d"/></dir><dir name="Block"><file name="Check.php" hash="24322e3ec477c16d99847e378e4f684d"/></dir><dir name="etc"><file name="api.xml" hash="c4bf74c7a340a02ff1f095b5371472f9"/><file name="config.xml" hash="dab54617a1f840f95f405434510edf1d"/><file name="system.xml" hash="093a9396a5915e29df53dcdfb596d7cd"/></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="01f753f938a2c3025e4286c1cb1a09af"/><file name="Price.php" hash="df91b573272cab2c1e6f86385a75bbae"/><file name="Product.php" hash="70b2a33d99fca8b3eacef7bd8419fb4e"/></dir><dir name="Model"><file name="Observer.php" hash="f0d803b0520bffdd7f14b56316efed0d"/><dir name="User"><file name="Api.php" hash="58413cb5f2d8002a4ff624927142b13b"/></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="511c4958ec2371481137085a795a0e3c"/></dir><dir name="Order"><file name="Api.php" hash="a66d742bc5011749a84da412b1b8ce32"/></dir><dir name="Attribute"><file name="Api.php" hash="4ed05d30baa43ed8a086066de22c8437"/></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="953b257a96841c5efadac97f0cf6614e"/></dir></dir></dir></dir></dir></dir></dir></target></contents></package>
|
