当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_ImportExport_Model_Import::getDataSourceModel方法代码示例

本文整理汇总了PHP中Mage_ImportExport_Model_Import::getDataSourceModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_ImportExport_Model_Import::getDataSourceModel方法的具体用法?PHP Mage_ImportExport_Model_Import::getDataSourceModel怎么用?PHP Mage_ImportExport_Model_Import::getDataSourceModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_ImportExport_Model_Import的用法示例。


在下文中一共展示了Mage_ImportExport_Model_Import::getDataSourceModel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBehavior

 /**
  * Retrive model behavior
  *
  * @return string
  */
 public function getBehavior()
 {
     if (is_null($this->_behavior)) {
         $this->_behavior = Mage_ImportExport_Model_Import::getDataSourceModel()->getBehavior();
     }
     return $this->_behavior;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:12,代码来源:Grouped.php

示例2: catalogProductImportFinishBefore

 public function catalogProductImportFinishBefore($observer)
 {
     $adapter = $observer->getEvent()->getAdapter();
     Mage_ImportExport_Model_Import::getDataSourceModel()->getIterator()->rewind();
     $model = Mage::getModel('catalog/product');
     $skus = array();
     while ($bunch = $adapter->getNextBunch()) {
         foreach ($bunch as $rowData) {
             if (null !== $rowData['sku']) {
                 $skus[] = $rowData['sku'];
             }
         }
     }
     if (!empty($skus)) {
         $resource = Mage::getResourceModel('jr_stockhistory/stock_history');
         $productIds = $resource->getProductsIdBySku($skus);
         if (!empty($productIds)) {
             $stock = Mage::getSingleton('cataloginventory/stock');
             $stocks = Mage::getResourceModel('cataloginventory/stock')->getProductsStock($stock, $productIds);
             $stocksHistory = array();
             $datetime = Varien_Date::formatDate(time());
             foreach ($stocks as $stockData) {
                 $stocksHistory[] = array('item_id' => $stockData['item_id'], 'user' => $this->_getUsername(), 'user_id' => $this->_getUserId(), 'qty' => $stockData['qty'], 'is_in_stock' => (int) $stockData['is_in_stock'], 'message' => 'Product import', 'created_at' => $datetime);
             }
             if (!empty($stocksHistory)) {
                 $resource->insertStocksHistory($stocksHistory);
             }
         }
     }
 }
开发者ID:r-martins,项目名称:magento-stock-history,代码行数:30,代码来源:Observer.php

示例3: catalogProductImportFinishBefore

 public function catalogProductImportFinishBefore($observer)
 {
     $productIds = array();
     $adapter = $observer->getEvent()->getAdapter();
     $resource = Mage::getResourceModel('bubble_stockmovements/stock_movement');
     if ($adapter instanceof Mage_Catalog_Model_Convert_Adapter_Product) {
         $productIds = $adapter->getAffectedEntityIds();
     } else {
         Mage_ImportExport_Model_Import::getDataSourceModel()->getIterator()->rewind();
         $skus = array();
         while ($bunch = $adapter->getNextBunch()) {
             foreach ($bunch as $rowData) {
                 if (null !== $rowData['sku']) {
                     $skus[] = $rowData['sku'];
                 }
             }
         }
         if (!empty($skus)) {
             $productIds = $resource->getProductsIdBySku($skus);
         }
     }
     if (!empty($productIds)) {
         $stock = Mage::getSingleton('cataloginventory/stock');
         $stocks = Mage::getResourceModel('cataloginventory/stock')->getProductsStock($stock, $productIds);
         $stocksMovements = array();
         $datetime = Varien_Date::formatDate(time());
         foreach ($stocks as $stockData) {
             $stocksMovements[] = array('item_id' => $stockData['item_id'], 'user' => $this->_getUsername(), 'user_id' => $this->_getUserId(), 'qty' => $stockData['qty'], 'is_in_stock' => (int) $stockData['is_in_stock'], 'message' => 'Product import', 'created_at' => $datetime);
         }
         if (!empty($stocksMovements)) {
             $resource->insertStocksMovements($stocksMovements);
         }
     }
 }
开发者ID:jadhub,项目名称:magento-stock-movements,代码行数:34,代码来源:Observer.php

示例4: testSaveValidatedBunches

 /**
  * Test for method _saveValidatedBunches()
  */
 public function testSaveValidatedBunches()
 {
     $source = new Mage_ImportExport_Model_Import_Adapter_Csv(__DIR__ . '/Entity/Eav/_files/customers_for_validation_test.csv');
     $expected = $source->current();
     /** @var $model Mage_ImportExport_Model_Import_EntityAbstract|PHPUnit_Framework_MockObject_MockObject */
     $model = $this->getMockForAbstractClass('Mage_ImportExport_Model_Import_EntityAbstract');
     $model->expects($this->any())->method('validateRow')->will($this->returnValue(true));
     $model->expects($this->any())->method('getEntityTypeCode')->will($this->returnValue('customer'));
     $model->setSource($source);
     $method = new ReflectionMethod($model, '_saveValidatedBunches');
     $method->setAccessible(true);
     $method->invoke($model);
     $dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel();
     $this->assertCount(1, $dataSourceModel->getIterator());
     $bunch = $dataSourceModel->getNextBunch();
     $this->assertEquals($expected, $bunch[0]);
     //Delete created bunch from DB
     $dataSourceModel->cleanBunches();
 }
开发者ID:nemphys,项目名称:magento2,代码行数:22,代码来源:EntityAbstractTest.php

示例5: __construct

 /**
  * Constructor.
  *
  */
 public function __construct()
 {
     $this->_dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel();
     $this->_connection = Mage::getSingleton('core/resource')->getConnection('write');
     $this->_initCategories();
     $this->_entityTable = Mage::getModel('catalog/category')->getResource()->getTable('catalog/category_product');
     $this->_productEntityTable = Mage::getModel('catalog/product')->getResource()->getEntityTable();
 }
开发者ID:hnsr,项目名称:AvS_FastSimpleImport,代码行数:12,代码来源:Product.php

示例6: __construct

 /**
  * Constructor.
  *
  * @return void
  */
 public function __construct()
 {
     $entityType = Mage::getSingleton('eav/config')->getEntityType($this->getEntityTypeCode());
     $this->_entityTypeId = $entityType->getEntityTypeId();
     $this->_dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel();
     $this->_connection = Mage::getSingleton('core/resource')->getConnection('write');
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:12,代码来源:Abstract.php

示例7: __construct

 /**
  * Constructor
  *
  * @param array $data
  */
 public function __construct(array $data = array())
 {
     if (isset($data['helpers'])) {
         $this->_helpers = $data['helpers'];
     }
     $this->_dataSourceModel = isset($data['data_source_model']) ? $data['data_source_model'] : Mage_ImportExport_Model_Import::getDataSourceModel();
     $this->_connection = isset($data['connection']) ? $data['connection'] : Mage::getSingleton('Mage_Core_Model_Resource')->getConnection('write');
     $this->_jsonHelper = isset($data['json_helper']) ? $data['json_helper'] : Mage::helper('Mage_Core_Helper_Data');
     $this->_stringHelper = isset($data['string_helper']) ? $data['string_helper'] : Mage::helper('Mage_Core_Helper_String');
     $this->_pageSize = isset($data['page_size']) ? $data['page_size'] : (static::XML_PATH_PAGE_SIZE ? (int) Mage::getStoreConfig(static::XML_PATH_PAGE_SIZE) : 0);
     $this->_maxDataSize = isset($data['max_data_size']) ? $data['max_data_size'] : Mage::getResourceHelper('Mage_ImportExport')->getMaxDataSize();
     $this->_bunchSize = isset($data['bunch_size']) ? $data['bunch_size'] : (static::XML_PATH_BUNCH_SIZE ? (int) Mage::getStoreConfig(static::XML_PATH_BUNCH_SIZE) : 0);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:18,代码来源:EntityAbstract.php

示例8: _initSourceEntities

 /**
  * Initialize source entities and collections
  *
  * @param array $data
  * @return Mage_ImportExport_Model_Import_Entity_Product_Option
  */
 protected function _initSourceEntities(array $data)
 {
     if (isset($data['data_source_model'])) {
         $this->_dataSourceModel = $data['data_source_model'];
     } else {
         $this->_dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel();
     }
     if (isset($data['product_model'])) {
         $this->_productModel = $data['product_model'];
     } else {
         $this->_productModel = Mage::getModel('Mage_Catalog_Model_Product');
     }
     if (isset($data['option_collection'])) {
         $this->_optionCollection = $data['option_collection'];
     } else {
         $this->_optionCollection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Option_Collection');
     }
     if (isset($data['product_entity'])) {
         $this->_productEntity = $data['product_entity'];
     } else {
         Mage::throwException($this->_helper('Mage_ImportExport_Helper_Data')->__('Option entity must have a parent product entity.'));
     }
     if (isset($data['collection_by_pages_iterator'])) {
         $this->_byPagesIterator = $data['collection_by_pages_iterator'];
     } else {
         $this->_byPagesIterator = Mage::getResourceModel('Mage_ImportExport_Model_Resource_CollectionByPagesIterator');
     }
     if (isset($data['page_size'])) {
         $this->_pageSize = $data['page_size'];
     } else {
         $this->_pageSize = self::XML_PATH_PAGE_SIZE ? (int) Mage::getStoreConfig(self::XML_PATH_PAGE_SIZE) : 0;
     }
     return $this;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:40,代码来源:Option.php


注:本文中的Mage_ImportExport_Model_Import::getDataSourceModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。