Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklooss/37879f317169d1182613 to your computer and use it in GitHub Desktop.
Save mklooss/37879f317169d1182613 to your computer and use it in GitHub Desktop.
Auto Add Items to Amazon Listing - m2e
<?php
if(php_sapi_name() != 'cli')
{
echo "only for cli!";
exit;
}
require 'app/Mage.php';
Mage::app('admin');
$listingId = 2;
$storeId = 1;
echo "start\n";
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('ean', array('notnull' => true))
->addStoreFilter($storeId)
->addAttributeToFilter('status', 1);
foreach($collection->getAllIds() as $_id)
{
$listing = Mage::helper('M2ePro/Component_Amazon')->getCachedObject('Listing', $listingId);
try {
$listing->addProduct($_id);
echo "product added {$_id}\n";
} catch(Exception $e)
{
echo "could not add {$_id}\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment