本文整理汇总了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;
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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');
}
示例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);
}
示例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;
}