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


PHP Mage_ImportExport_Model_Import类代码示例

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


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

示例1: 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

示例2: setUpBeforeClass

 /**
  * Add behaviour fieldsets to expected fieldsets
  *
  * @static
  */
 public static function setUpBeforeClass()
 {
     $uniqueBehaviors = Mage_ImportExport_Model_Import::getUniqueEntityBehaviors();
     foreach (array_keys($uniqueBehaviors) as $behavior) {
         self::$_expectedFieldsets[] = $behavior . '_fieldset';
     }
 }
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:12,代码来源:Form.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: 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

示例5: _initAttributes

 /**
  * Adds bundle price type to internal attributes.
  *
  * @return Danslo_ApiImport_Model_Import_Entity_Product_Type_Bundle
  */
 public function _initAttributes()
 {
     parent::_initAttributes();
     // Price type does not live in an attribute set, so it is not picked up by abstract _initAttributes method. We add it here manually.
     $attribute = Mage::getResourceModel('catalog/eav_attribute')->load('price_type', 'attribute_code');
     foreach (array_keys($this->_attributes) as $attrSetName) {
         $this->_addAttributeParams($attrSetName, array('id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'for_configurable' => $attribute->getIsConfigurable(), 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'is_unique' => $attribute->getIsUnique(), 'frontend_label' => $attribute->getFrontendLabel(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes)));
     }
     return $this;
 }
开发者ID:gaileverett,项目名称:ApiImport,代码行数:15,代码来源:Bundle.php

示例6: _initAttributes

 /**
  * Initialize attributes parameters for all attributes' sets.
  *
  * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
  */
 protected function _initAttributes()
 {
     // temporary storage for attributes' parameters to avoid double querying inside the loop
     $attributesCache = array();
     foreach (Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
         foreach (Mage::getResourceModel('catalog/product_attribute_collection')->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
             $attributeCode = $attribute->getAttributeCode();
             $attributeId = $attribute->getId();
             if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
                 if (!isset($attributesCache[$attributeId])) {
                     $attributesCache[$attributeId] = array('id' => $attributeId, 'code' => $attributeCode, 'for_configurable' => $attribute->getIsConfigurable(), 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'frontend_label' => $attribute->getFrontendLabel(), 'frontend_input' => $attribute->getFrontendInput(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes));
                 }
                 $this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId]);
             }
         }
     }
     return $this;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:23,代码来源:Grouped.php

示例7: 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

示例8: _prepareForm

 /**
  * Add fieldsets
  *
  * @return Mage_ImportExport_Block_Adminhtml_Import_Edit_Form
  */
 protected function _prepareForm()
 {
     $helper = Mage::helper('Mage_ImportExport_Helper_Data');
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/validate'), 'method' => 'post', 'enctype' => 'multipart/form-data'));
     // base fieldset
     /** @var $importEntity Mage_ImportExport_Model_Source_Import_Entity */
     $importEntity = Mage::getModel('Mage_ImportExport_Model_Source_Import_Entity');
     $fieldsets['base'] = $form->addFieldset('base_fieldset', array('legend' => $helper->__('Import Settings')));
     $fieldsets['base']->addField('entity', 'select', array('name' => 'entity', 'title' => $helper->__('Entity Type'), 'label' => $helper->__('Entity Type'), 'required' => true, 'onchange' => 'varienImport.handleEntityTypeSelector();', 'values' => $importEntity->toOptionArray()));
     // add behaviour fieldsets
     $uniqueBehaviors = Mage_ImportExport_Model_Import::getUniqueEntityBehaviors();
     foreach ($uniqueBehaviors as $behaviorCode => $behaviorClass) {
         $fieldsets[$behaviorCode] = $form->addFieldset($behaviorCode . '_fieldset', array('legend' => $helper->__('Import Behavior'), 'style' => 'display:none'));
         /** @var $behaviorSource Mage_ImportExport_Model_Source_Import_BehaviorAbstract */
         $behaviorSource = Mage::getModel($behaviorClass);
         $fieldsets[$behaviorCode]->addField($behaviorCode, 'select', array('name' => 'behavior', 'title' => $helper->__('Import Behavior'), 'label' => $helper->__('Import Behavior'), 'required' => true, 'disabled' => true, 'values' => $behaviorSource->toOptionArray()));
     }
     // fieldset for file uploading
     $fieldsets['upload'] = $form->addFieldset('upload_file_fieldset', array('legend' => $helper->__('File to Import'), 'style' => 'display:none'));
     $fieldsets['upload']->addField(Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'file', array('name' => Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE, 'label' => $helper->__('Select File to Import'), 'title' => $helper->__('Select File to Import'), 'required' => true));
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:natxetee,项目名称:magento2,代码行数:29,代码来源:Form.php

示例9: __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

示例10: __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

示例11: _initAttributes

 /**
  * Initialize customer attributes.
  *
  * @return Mage_ImportExport_Model_Import_Entity_Customer
  */
 protected function _initAttributes()
 {
     $collection = Mage::getResourceModel('customer/attribute_collection')->addSystemHiddenFilterWithPasswordHash();
     foreach ($collection as $attribute) {
         $this->_attributes[$attribute->getAttributeCode()] = array('id' => $attribute->getId(), 'is_required' => $attribute->getIsRequired(), 'is_static' => $attribute->isStatic(), 'rules' => $attribute->getValidateRules() ? unserialize($attribute->getValidateRules()) : null, 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), 'options' => $this->getAttributeOptions($attribute));
     }
     return $this;
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:13,代码来源:Customer.php

示例12: _initAttributes

 /**
  * Initialize customer address attributes.
  *
  * @return Mage_ImportExport_Model_Import_Entity_Customer_Address
  */
 protected function _initAttributes()
 {
     $addrCollection = Mage::getResourceModel('customer/address_attribute_collection')->addSystemHiddenFilter()->addExcludeHiddenFrontendFilter();
     foreach ($addrCollection as $attribute) {
         $this->_attributes[self::getColNameForAttrCode($attribute->getAttributeCode())] = array('id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'table' => $attribute->getBackend()->getTable(), 'is_required' => $attribute->getIsRequired(), 'rules' => $attribute->getValidateRules() ? unserialize($attribute->getValidateRules()) : null, 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute), 'options' => $this->getAttributeOptions($attribute));
     }
     return $this;
 }
开发者ID:okite11,项目名称:frames21,代码行数:13,代码来源:Address.php

示例13: _initAttributes

 /**
  * Initialize attribute option values and types.
  *
  * @return Mage_ImportExport_Model_Export_Entity_Product
  */
 protected function _initAttributes()
 {
     foreach ($this->getAttributeCollection() as $attribute) {
         $this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute);
         $this->_attributeTypes[$attribute->getAttributeCode()] = Mage_ImportExport_Model_Import::getAttributeType($attribute);
     }
     return $this;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:13,代码来源:Product.php

示例14: _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

示例15: getBehavior

 /**
  * Import behavior getter.
  *
  * @return string
  */
 public function getBehavior()
 {
     if (!isset($this->_parameters['behavior']) || $this->_parameters['behavior'] != Mage_ImportExport_Model_Import::BEHAVIOR_APPEND && $this->_parameters['behavior'] != Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE && $this->_parameters['behavior'] != Mage_ImportExport_Model_Import::BEHAVIOR_DELETE) {
         return Mage_ImportExport_Model_Import::getDefaultBehavior();
     }
     return $this->_parameters['behavior'];
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:12,代码来源:Abstract.php


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