danslo / ApiImport

Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.
244 stars 79 forks source link

Enhancement/image support #17

Closed willy-ahva closed 10 years ago

willy-ahva commented 10 years ago

Here is a PR to : Add image support : now you can import image directly via Soap.

Enhance benchmark :

danslo commented 10 years ago

I'm tagging myself here so I can review this later and possibly do some cleanup/merging of the request.

Thanks for your contribution! :-)

willy-ahva commented 10 years ago

You're welcome ! You can do what you want about this code ;)

willy-ahva commented 10 years ago

Do you know if it's possible, in an api like AiImport, to use the same method than the "Check Data" button from the page where you can import a CSV file in Magento ? And if yes, what are those methods ? Thanks for help @danslo :)

danslo commented 10 years ago

@willy-ahva It's not currently possible, but should be easy to add.

This is how Magento does it: https://github.com/OpenMage/magento-mirror/blob/magento-1.8/app/code/core/Mage/ImportExport/Model/Import.php#L440

Basically all you need to do is add something like this to Danslo_ApiImport_Model_Import_Api:

public function validateEntities($entities, $entityType = null, $behavior = null)
{
    // Not sure if these are needed when validating.
    $this->_setEntityTypeCode($entityType ? $entityType : Mage_Catalog_Model_Product::ENTITY);
    $this->_setBehavior($behavior ? $behavior : Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE);

    $this->_api->getDataSourceModel()->setEntities($entities);
    return array($this->_api->isDataValid());
}

And then obviously update wsdl.xml and api.xml. Haven't tested the above, but it should work.

drewdotpro commented 10 years ago

I'd love to see this PR merged I've done a (light) code review and it looks solid.

danslo commented 10 years ago

@drewdotpro I'm getting this merged pretty soon, I just want to make some slight adjustments but haven't gotten around to it unfortunately.