Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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
-------
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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'));

Expand All @@ -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];
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/app/code/community/AvS/FastSimpleImport/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<import_entity_product>AvS_FastSimpleImport_Model_Import_Entity_Product</import_entity_product>
</rewrite>
</importexport>
<enterprise_importexport>
<rewrite>
<import_entity_product>AvS_FastSimpleImport_Model_Import_Entity_Product</import_entity_product>
</rewrite>
</enterprise_importexport>
</models>

<helpers>
Expand Down