Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to import downloadable products with downloadable links #352

Merged
merged 5 commits into from
Jul 3, 2017

Conversation

Maksold
Copy link
Contributor

@Maksold Maksold commented Sep 16, 2016

No description provided.

@Maksold
Copy link
Contributor Author

Maksold commented Sep 16, 2016

Here is sample code for importing downloadable product with downloadable link:

<?php
require 'app/Mage.php';
Mage::app();

$data = array(
    array(
        'sku' => '1234759567',
        '_type' => 'downloadable',
        '_attribute_set' => 'Default',
        '_product_websites' => 'base',
        'name' => 'Downloadable Product',
        'price' => 0.99,
        'description' => 'Default',
        'short_description' => 'Default',
        'weight' => 0,
        'status' => 1,
        'visibility' => 4,
        'tax_class_id' => 2,
        'qty' => 76,
        'downloadable_links_file' => 'https://upload.wikimedia.org/wikipedia/commons/c/c4/PM5544_with_non-PAL_signals.png',
        'downloadable_links_title' => 'PM5544_with_non-PAL_signals.png',
        'downloadable_links_nod' => '100',
    ),
    // add more products here
);

/** @var $import AvS_FastSimpleImport_Model_Import */
$import = Mage::getModel('fastsimpleimport/import');
try {
    $import->processProductImport($data);
} catch (Exception $e) {
    print_r($import->getErrorMessages());
}

@Maksold
Copy link
Contributor Author

Maksold commented Sep 19, 2016

@avstudnitz, @paales could you please approve this pull request?

EliasKotlyar and others added 3 commits October 6, 2016 13:32
[Downloadable] Links Purchase Attribute is now inserted
Setting preprocessDownloadableFile option to product import
@avstudnitz
Copy link
Owner

@Maksold @EliasKotlyar Thank you both!
When I try to import with the given example script, I am getting the following error:

Array
(
    [Required attribute 'links_purchased_separately' has an empty value] => Array
        (
            [0] => 1
        )

)

@Maksold
Copy link
Contributor Author

Maksold commented Apr 18, 2017

It's because if forgot to add requred 'links_purchased_separately' attribute. Here is working code:

<?php
require 'app/Mage.php';
Mage::app();

$data = array(
    array(
        'sku' => '1234759567',
        '_type' => 'downloadable',
        '_attribute_set' => 'Default',
        '_product_websites' => 'base',
        'name' => 'Downloadable Product',
        'price' => 0.99,
        'description' => 'Default',
        'short_description' => 'Default',
        'weight' => 0,
        'status' => 1,
        'visibility' => 4,
        'tax_class_id' => 2,
        'qty' => 76,
        'downloadable_links_file' => 'https://upload.wikimedia.org/wikipedia/commons/c/c4/PM5544_with_non-PAL_signals.png',
        'downloadable_links_title' => 'PM5544_with_non-PAL_signals.png',
        'downloadable_links_nod' => '100',
        'links_purchased_separately' => '1'
    ),
    // add more products here
);

/** @var $import AvS_FastSimpleImport_Model_Import */
$import = Mage::getModel('fastsimpleimport/import');
try {
    $import->processProductImport($data);
} catch (Exception $e) {
    print_r($import->getErrorMessages());
}

@avstudnitz Can you please merge this pull request?

@norgeindian
Copy link

Just tested your improvement. Works fine so far, thanks a lot!

There are just three things which should be improved in my opinion:

  1. We did not have the folder downloadable/files/links in our media directory. In this case, the download files are not created and so no download file is uploaded.
    So it should first be guaranteed, that this folder exists or it should be created if not.
  2. As Magento saves such files in multiple sub-folders (your example URL for example is stored in downloadable/files/links/p/m, when you upload it manually in the Magento backend), it would also be great, if we do it the same way.
  3. Another issue I found is the download link.
    Right now all download links are imported as files.
    It would be perfect to have the option to import them as URL, too.
    Therefore, two new array keys would be good: One for the URL (downloadable_links_url) and one for the type (downloadable_links_type).

@avstudnitz @nhp Could you please merge this pull request?
@Maksold Do you want to work on my ideas or should I implement it by myself as soon as it is merged and provide another PR?

@avstudnitz avstudnitz merged commit 797a3f0 into avstudnitz:develop Jul 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants