本文整理汇总了PHP中Mage_ImportExport_Model_Import类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_ImportExport_Model_Import类的具体用法?PHP Mage_ImportExport_Model_Import怎么用?PHP Mage_ImportExport_Model_Import使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_ImportExport_Model_Import类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: _initAttributes
/**
* Initialize customer attributes.
*
* @return $this
*/
protected function _initAttributes()
{
$collection = Mage::getResourceModel('catalog/category_attribute_collection');
foreach ($collection as $attribute) {
/** @var $attribute Mage_Eav_Model_Entity_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), 'attribute' => $attribute);
}
return $this;
}
开发者ID:tinchodev,项目名称:AvS_FastSimpleImport,代码行数:14,代码来源:Category.php
示例17: array
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
$pattern = array('_attribute_set' => 'Default', '_type' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, '_product_websites' => 'base', 'name' => 'Product %s', 'short_description' => 'Short desc %s', 'weight' => 1, 'description' => 'Description %s', 'sku' => 'product_dynamic_%s', 'price' => 10, 'visibility' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, 'status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED, 'tax_class_id' => 0, 'is_in_stock' => 1, 'qty' => 100500, 'use_config_min_qty' => '1', 'use_config_backorders' => '1', 'use_config_min_sale_qty' => '1', 'use_config_max_sale_qty' => '1', 'use_config_notify_stock_qty' => '1', 'use_config_manage_stock' => '1', 'use_config_qty_increments' => '1', 'use_config_enable_qty_inc' => '1', 'stock_id' => Mage_CatalogInventory_Model_Stock::DEFAULT_STOCK_ID);
$generator = new Magento_ImportExport_Fixture_Generator($pattern, 100000);
$import = new Mage_ImportExport_Model_Import(array('entity' => 'catalog_product', 'behavior' => 'append'));
// it is not obvious, but the validateSource() will actually save import queue data to DB
$import->validateSource($generator);
// this converts import queue into actual entities
$import->importSource();
开发者ID:nemphys,项目名称:magento2,代码行数:31,代码来源:catalog_100k_products.php
示例18: testGetEntityEntityIsNotSet
/**
* @expectedException Mage_Core_Exception
* @expectedExceptionMessage Entity is unknown
*/
public function testGetEntityEntityIsNotSet()
{
$this->_model->getEntity();
}
开发者ID:rorteg,项目名称:magento2,代码行数:8,代码来源:ImportTest.php
示例19: _getSourceAdapter
/**
* Returns source adapter object.
*
* @param array $sourceData Array Source Data
*
* @return AvS_FastSimpleImport_Model_ArrayAdapter
*/
protected function _getSourceAdapter($sourceData)
{
if (is_array($sourceData)) {
if ($this->getUseNestedArrays()) {
return Mage::getModel('fastsimpleimport/nestedArrayAdapter', $sourceData);
} else {
return Mage::getModel('fastsimpleimport/arrayAdapter', $sourceData);
}
}
return parent::_getSourceAdapter($sourceData);
}
开发者ID:helirexi,项目名称:AvS_FastSimpleImport,代码行数:18,代码来源:Import.php
注:本文中的Mage_ImportExport_Model_Import类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论