Пример #1
0
 /**
  * Verify that all stock item attribute values are exported (aren't equal to empty string)
  *
  * @covers Mage_ImportExport_Model_Export_Entity_Product::export
  * @magentoDataFixture Mage/ImportExport/_files/product.php
  */
 public function testExportStockItemAttributesAreFilled()
 {
     $writerMock = $this->getMockForAbstractClass('Mage_ImportExport_Model_Export_Adapter_Abstract', array(), '', true, true, true, array('setHeaderCols', 'writeRow'));
     $writerMock->expects($this->any())->method('setHeaderCols')->will($this->returnCallback(array($this, 'verifyHeaderColumns')));
     $writerMock->expects($this->any())->method('writeRow')->will($this->returnCallback(array($this, 'verifyRow')));
     $this->_model->setWriter($writerMock)->export();
 }
Пример #2
0
 /**
  * Apply filter to collection and add not skipped attributes to select.
  *
  * Supports adding of additional parameter $filteredProductIds that allows to extend filtering
  * base Magento filtering, provided by parent::_prepareEntityCollection() method.
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  * @param array $filteredIds
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 protected function _prepareMepEntityCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection, $filteredIds)
 {
     /* @var $obj_profile Flagbit_MEP_Model_Profile */
     $obj_profile = $this->getProfile();
     /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
     $collection = parent::_prepareEntityCollection($collection);
     $collection->setStoreId(0)->addStoreFilter($obj_profile->getStoreId());
     $collection->addFieldToFilter("entity_id", array('in' => $filteredIds));
     return $collection;
 }
Пример #3
0
 * limitations under the License.
 */
require_once 'app/Mage.php';
Mage::init();
define('NUM_ENTITIES', 5000);
define('API_USER', 'apiUser');
define('API_KEY', 'someApiKey123');
define('USE_API', true);
$helper = Mage::helper('api_import/test');
if (USE_API) {
    // Create an API connection. Standard timeout for Zend_Http_Client is 10 seconds, so we must lengthen it.
    $client = new Zend_XmlRpc_Client(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'api/xmlrpc/');
    $client->getHttpClient()->setConfig(array('timeout' => -1));
    $session = $client->call('login', array(API_USER, API_KEY));
}
$entityTypes = array('product' => array('entity' => Mage_ImportExport_Model_Export_Entity_Product::getEntityTypeCode(), 'model' => 'catalog/product', 'types' => array('simple', 'configurable', 'bundle', 'grouped')), 'customer' => array('entity' => Mage_ImportExport_Model_Export_Entity_Customer::getEntityTypeCode(), 'model' => 'customer/customer', 'types' => array('standard')), 'category' => array('entity' => Danslo_ApiImport_Model_Import_Entity_Category::getEntityTypeCode(), 'model' => 'catalog/category', 'types' => array('standard')));
foreach ($entityTypes as $typeName => $entityType) {
    foreach ($entityType['types'] as $subType) {
        // Generation method depends on product type.
        printf('Generating %d %s %ss...' . PHP_EOL, NUM_ENTITIES, $subType, $typeName);
        $entities = $helper->{sprintf('generateRandom%s%s', ucfirst($subType), ucfirst($typeName))}(NUM_ENTITIES);
        // Attempt to import generated products.
        printf('Starting import...' . PHP_EOL);
        $totalTime = microtime(true);
        if (USE_API) {
            try {
                $client->call('call', array($session, 'import.importEntities', array($entities, $entityType['entity'])));
            } catch (Exception $e) {
                printf('Import failed: ' . PHP_EOL, $e->getMessage());
                printf('Server returned: %s' . PHP_EOL, $client->getHttpClient()->getLastResponse()->getBody());
                exit;
define('API_USER', 'apiUser');
define('API_KEY', 'someApiKey123');
define('USE_API', true);
ini_set('memory_limit', '2048M');
$helper = Mage::helper('api_import/test');
if (USE_API) {
    // Create an API connection
    $soapOptions = array('encoding' => 'UTF-8', 'trace' => true, 'exceptions' => true, 'login' => API_USER, 'password' => API_KEY, 'cache_wsdl' => 3, 'keep_alive' => 1);
    try {
        $client = new SoapClient(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'index.php/api/soap/?wsdl', $soapOptions);
        $session = $client->login(API_USER, API_KEY);
    } catch (Exception $e) {
        echo 'Exception :' . $e->getMessage();
    }
}
$entityTypes = array('product' => array('entity' => Mage_ImportExport_Model_Export_Entity_Product::getEntityTypeCode(), 'model' => 'catalog/product', 'types' => array('simple', 'configurable', 'bundle', 'grouped', 'image', 'localizable'), 'behavior' => 'append'), 'attributeSets' => array('entity' => 'attributeSets', 'types' => array('standard'), 'behavior' => 'append'), 'attributes' => array('entity' => 'attributes', 'types' => array('standard'), 'behavior' => 'append'), 'attributeAssociations' => array('entity' => 'attributeAssociations', 'types' => array('standard'), 'behavior' => 'append'), 'customer' => array('entity' => Mage_ImportExport_Model_Export_Entity_Customer::getEntityTypeCode(), 'model' => 'customer/customer', 'types' => array('standard'), 'behavior' => 'append'), 'category' => array('entity' => Danslo_ApiImport_Model_Import_Entity_Category::getEntityTypeCode(), 'model' => 'catalog/category', 'types' => array('standard'), 'behavior' => 'append'));
foreach ($entityTypes as $typeName => $entityType) {
    foreach ($entityType['types'] as $subType) {
        // Generation method depends on product type.
        printf('Generating %d %s %ss...' . PHP_EOL, NUM_ENTITIES, $subType, $typeName);
        $entities = $helper->{sprintf('generateRandom%s%s', ucfirst($subType), ucfirst($typeName))}(NUM_ENTITIES);
        // Attempt to import generated products.
        printf('Starting import...' . PHP_EOL);
        $totalTime = microtime(true);
        if (USE_API) {
            $data = array();
            if (count($entities) <= NUM_ROWS_BY_CALL || !NUM_ROWS_BY_CALL) {
                $data[] = $entities;
            } else {
                $data = array_chunk($entities, NUM_ROWS_BY_CALL);
            }