diff --git a/README.markdown b/README.markdown
index 52776b27..dd6c2a75 100644
--- a/README.markdown
+++ b/README.markdown
@@ -7,12 +7,9 @@ Wrapper for Magento ImportExport functionality which imports data from arrays
Facts
-----
-- version: 0.7.0
+- version: 0.8.2
- extension key: AvS_FastSimpleImport
-- extension on Magento Connect: n/a
-- Magento Connect 1.0 extension key: n/a
-- Magento Connect 2.0 extension key: n/a
-- Composer name: avstudnitz/fast-simple-import (included in http://packages.firegento.com/)
+- Composer name: avstudnitz/fast-simple-import (included in http://packages.firegento.com/ and Packagist)
- [Extension on GitHub](https://github.com/avstudnitz/AvS_FastSimpleImport)
- [Direct download link](https://github.com/avstudnitz/AvS_FastSimpleImport/tarball/master)
- [Documentation](http://avstudnitz.github.io/AvS_FastSimpleImport/)
@@ -73,6 +70,10 @@ Paul Hachmang
http://www.h-o.nl/
[@paales](https://twitter.com/paales)
+Simon Sprankel
+http://simonsprankel.de/
+[@SimonSprankel](https://twitter.com/SimonSprankel)
+
License
-------
diff --git a/composer.json b/composer.json
index 9f2f19d4..9fd3e5e4 100644
--- a/composer.json
+++ b/composer.json
@@ -3,6 +3,9 @@
"type": "magento-module",
"description": "Wrapper for Magento ImportExport functionality, which imports products and customers from arrays",
"homepage": "https://github.com/avstudnitz/AvS_FastSimpleImport",
+ "license": [
+ "OSL-3.0"
+ ],
"suggest": {
"magento-hackathon/magento-composer-installer": "*"
}
diff --git a/src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php b/src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php
index 927922ee..20fec9d9 100644
--- a/src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php
+++ b/src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php
@@ -98,7 +98,7 @@ class AvS_FastSimpleImport_Model_Import_Entity_Product extends AvS_FastSimpleImp
protected $_mediaValueTableName;
/** @var string */
protected $_downloadableLinksTableName;
-
+
/**
* Attributes with index (not label) value.
*
@@ -1394,18 +1394,26 @@ protected function _saveProducts()
$mediaGallery[$rowSku][] = $mediaImageData;
}
- // 4. Downloadable files phase
- if (!empty($rowData['downloadable_links_file']) &&
- !empty($rowData['downloadable_links_title']) &&
+ // 4. Downloadable links phase
+ if (!empty($rowData['downloadable_links_title']) &&
!empty($rowData['downloadable_links_nod']) &&
$rowData['_type'] === 'downloadable') {
- $downloadableLinkData = array(
+ $downloadableLinkData = [
'title' => $rowData['downloadable_links_title'],
'number_of_downloads' => $rowData['downloadable_links_nod'],
- 'file' => $rowData['downloadable_links_file'],
'store_id' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID
- );
+ ];
+
+ // downloadable files
+ if (!empty($rowData['downloadable_links_file'])) {
+ $downloadableLinkData['file'] = $rowData['downloadable_links_file'];
+ $downloadableLinkData['link_type'] = 'file';
+ // downloadable urls
+ } elseif (!empty($rowData['downloadable_links_url'])) {
+ $downloadableLinkData['url'] = $rowData['downloadable_links_url'];
+ $downloadableLinkData['link_type'] = 'url';
+ }
$downloadableData[$rowSku][] = $downloadableLinkData;
}
@@ -1561,6 +1569,7 @@ protected function _saveStockItem()
/** @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
$stockItem = Mage::getModel('cataloginventory/stock_item');
+ $stockItem->setStockId($row['stock_id']);
$stockItem->loadByProduct($row['product_id']);
$existStockData = $stockItem->getData();
@@ -2047,19 +2056,29 @@ protected function _saveDownloadableLinks(array $downloadableData)
}
foreach ($downloadableLink as $insertValue) {
+
+ $linkType = $insertValue['link_type'];
+ $fieldToSelect = 'link_' . $linkType;
+
$alreadyImported = $this->_connection->fetchOne($this->_connection->select()
- ->from($downloadableLinkTableName, array('link_file'))
+ ->from($downloadableLinkTableName, array($fieldToSelect))
->where('product_id IN (?)', $productId)
- ->where('link_file = (?)', $insertValue['file']));
+ ->where("$fieldToSelect = (?)", $insertValue[$linkType]));
- if (!in_array($insertValue['file'], $insertedDownloadableLinks) && !$alreadyImported) {
+ if (!in_array($insertValue[$linkType], $insertedDownloadableLinks) && !$alreadyImported) {
$valueArr = array(
'product_id' => $productId,
- 'link_file' => $insertValue['file'],
- 'link_type' => 'file',
'number_of_downloads' => $insertValue['number_of_downloads'],
);
+ if (array_key_exists('file', $insertValue)) {
+ $valueArr['link_file'] = $insertValue['file'];
+ $valueArr['link_type'] = 'file';
+ } elseif (array_key_exists('url', $insertValue)) {
+ $valueArr['link_url'] = $insertValue['url'];
+ $valueArr['link_type'] = 'url';
+ }
+
$this->_connection
->insertOnDuplicate($downloadableLinkTableName, $valueArr, array('product_id'));
@@ -2074,10 +2093,12 @@ protected function _saveDownloadableLinks(array $downloadableData)
$this->_connection
->insertOnDuplicate($downloadableLinkTitleTableName, $valueArr, array('link_id'));
- $this->moveDownloadableFile($insertValue['file']);
- $insertedDownloadableLinks[] = $insertValue['file'];
-
-
+ if ($linkType == 'file') {
+ $this->moveDownloadableFile($insertValue[$fieldToSelect]);
+ }
+ if (array_key_exists($fieldToSelect, $insertValue)) {
+ $insertedDownloadableLinks[] = $insertValue[$fieldToSelect];
+ }
}
}
}
diff --git a/src/app/code/community/AvS/FastSimpleImport/etc/config.xml b/src/app/code/community/AvS/FastSimpleImport/etc/config.xml
index 37401191..444a935a 100644
--- a/src/app/code/community/AvS/FastSimpleImport/etc/config.xml
+++ b/src/app/code/community/AvS/FastSimpleImport/etc/config.xml
@@ -24,6 +24,11 @@
AvS_FastSimpleImport_Model_Import_Entity_Product
+
+
+ AvS_FastSimpleImport_Model_Import_Entity_Product
+
+