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


PHP Mage_Core_Model_Factory::getModel方法代码示例

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


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

示例1: _getClient

 /**
  * Retrieve client instance
  *
  * @param string $metadataTableName
  * @return Enterprise_Mview_Model_Client
  */
 protected function _getClient($metadataTableName)
 {
     /** @var $client Enterprise_Mview_Model_Client */
     $client = $this->_factory->getModel('enterprise_mview/client', array(array('factory' => $this->_factory)));
     $client->init($metadataTableName);
     return $client;
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:13,代码来源:Url.php

示例2: login

 /**
  * Try to login user in admin
  *
  * @param  string $username
  * @param  string $password
  * @param  Mage_Core_Controller_Request_Http $request
  * @return Mage_Admin_Model_User|null
  */
 public function login($username, $password, $request = null)
 {
     if (empty($username) || empty($password)) {
         return;
     }
     try {
         /** @var $user Mage_Admin_Model_User */
         $user = $this->_factory->getModel('admin/user');
         $user->login($username, $password);
         if ($user->getId()) {
             $this->renewSession();
             if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
                 Mage::getSingleton('adminhtml/url')->renewSecretUrls();
             }
             $this->setIsFirstPageAfterLogin(true);
             $this->setUser($user);
             $this->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
             $alternativeUrl = $this->_getRequestUri($request);
             $redirectUrl = $this->_urlPolicy->getRedirectUrl($user, $request, $alternativeUrl);
             if ($redirectUrl) {
                 Mage::dispatchEvent('admin_session_user_login_success', array('user' => $user));
                 $this->_response->clearHeaders()->setRedirect($redirectUrl)->sendHeadersAndExit();
             }
         } else {
             Mage::throwException(Mage::helper('adminhtml')->__('Invalid User Name or Password.'));
         }
     } catch (Mage_Core_Exception $e) {
         Mage::dispatchEvent('admin_session_user_login_failed', array('user_name' => $username, 'exception' => $e));
         if ($request && !$request->getParam('messageSent')) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
             $request->setParam('messageSent', true);
         }
     }
     return $user;
 }
开发者ID:nja78,项目名称:Magento-Pre-Patched-Files,代码行数:43,代码来源:Session.php

示例3: _prepareAffectedProduct

 /**
  * Prepare affected product
  */
 protected function _prepareAffectedProduct()
 {
     /** @var $modelCondition Mage_Catalog_Model_Product_Condition */
     $modelCondition = $this->_factory->getModel('catalog/product_condition');
     $productCondition = $modelCondition->setTable($this->_resource->getTable('catalogrule/affected_product'))->setPkFieldName('product_id');
     $this->_app->dispatchEvent('catalogrule_after_apply', array('product' => $this->_getProduct(), 'product_condition' => $productCondition));
     $this->_connection->delete($this->_resource->getTable('catalogrule/affected_product'));
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:11,代码来源:Refresh.php

示例4: deleteOrphanRedirects

 /**
  * Listener for after category/product delete event. Delete orphan redirects from index.
  *
  * @param Varien_Event_Observer $observer
  */
 public function deleteOrphanRedirects(Varien_Event_Observer $observer)
 {
     if ((string) $this->_app->getConfig()->getNode(Enterprise_UrlRewrite_Model_Index_Observer::XML_PATH_REDIRECT_URL_SUFFIX_UPDATE_ON_SAVE)) {
         /** @var $client Enterprise_Mview_Model_Client */
         $client = $this->_factory->getModel('enterprise_mview/client')->init('enterprise_url_rewrite_redirect');
         $client->execute('enterprise_urlrewrite/index_action_url_rewrite_redirect_refresh_orphan');
     }
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:13,代码来源:Observer.php

示例5: __construct

 /**
  * Constructor
  * Arguments:
  *   request  - Zend_Controller_Request_Http
  *   config   - Mage_Core_Model_Config
  *   factory  - Mage_Core_Model_Factory
  *   routers  - array
  *
  * @param array $args
  */
 public function __construct(array $args)
 {
     $this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getModel('core/factory');
     $this->_app = !empty($args['app']) ? $args['app'] : Mage::app();
     $this->_config = !empty($args['config']) ? $args['config'] : Mage::getConfig();
     $this->_request = !empty($args['request']) ? $args['request'] : Mage::app()->getFrontController()->getRequest();
     $this->_rewrite = !empty($args['rewrite']) ? $args['rewrite'] : $this->_factory->getModel('core/url_rewrite');
     if (!empty($args['routers'])) {
         $this->_routers = $args['routers'];
     }
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:21,代码来源:Request.php

示例6: _getRegions

 /**
  * Get Regions for specific Countries
  * @param string $storeId
  * @return array|null
  */
 protected function _getRegions($storeId)
 {
     $countryIds = array();
     $countryCollection = $this->getCountryCollection()->loadByStore($storeId);
     foreach ($countryCollection as $country) {
         $countryIds[] = $country->getCountryId();
     }
     /** @var $regionModel Mage_Directory_Model_Region */
     $regionModel = $this->_factory->getModel('directory/region');
     /** @var $collection Mage_Directory_Model_Resource_Region_Collection */
     $collection = $regionModel->getResourceCollection()->addCountryFilter($countryIds)->load();
     $regions = array('config' => array('show_all_regions' => $this->getShowNonRequiredState(), 'regions_required' => $this->getCountriesWithStatesRequired()));
     foreach ($collection as $region) {
         if (!$region->getRegionId()) {
             continue;
         }
         $regions[$region->getCountryId()][$region->getRegionId()] = array('code' => $region->getCode(), 'name' => $this->__($region->getName()));
     }
     return $regions;
 }
开发者ID:monkviper,项目名称:magento-lite,代码行数:25,代码来源:Data.php

示例7: insertRuleData

 /**
  * Inserts rule data into catalogrule/rule_product table
  *
  * @param Mage_CatalogRule_Model_Rule $rule
  * @param array $websiteIds
  * @param array $productIds
  */
 public function insertRuleData(Mage_CatalogRule_Model_Rule $rule, array $websiteIds, array $productIds = array())
 {
     /** @var $write Varien_Db_Adapter_Interface */
     $write = $this->_getWriteAdapter();
     $customerGroupIds = $rule->getCustomerGroupIds();
     $fromTime = (int) strtotime($rule->getFromDate());
     $toTime = (int) strtotime($rule->getToDate());
     $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0;
     /** @var Mage_Core_Model_Date $coreDate */
     $coreDate = $this->_factory->getModel('core/date');
     $timestamp = $coreDate->gmtTimestamp('Today');
     if ($fromTime > $timestamp || $toTime && $toTime < $timestamp) {
         return;
     }
     $sortOrder = (int) $rule->getSortOrder();
     $actionOperator = $rule->getSimpleAction();
     $actionAmount = (double) $rule->getDiscountAmount();
     $subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : '';
     $subActionAmount = (double) $rule->getSubDiscountAmount();
     $actionStop = (int) $rule->getStopRulesProcessing();
     /** @var $helper Mage_Catalog_Helper_Product_Flat */
     $helper = $this->_factory->getHelper('catalog/product_flat');
     if ($helper->isEnabled() && $helper->isBuiltAllStores()) {
         /** @var $store Mage_Core_Model_Store */
         foreach ($this->_app->getStores(false) as $store) {
             if (in_array($store->getWebsiteId(), $websiteIds)) {
                 /** @var $selectByStore Varien_Db_Select */
                 $selectByStore = $rule->getProductFlatSelect($store->getId())->joinLeft(array('cg' => $this->getTable('customer/customer_group')), $write->quoteInto('cg.customer_group_id IN (?)', $customerGroupIds), array('cg.customer_group_id'))->reset(Varien_Db_Select::COLUMNS)->columns(array(new Zend_Db_Expr($store->getWebsiteId()), 'cg.customer_group_id', 'p.entity_id', new Zend_Db_Expr($rule->getId()), new Zend_Db_Expr($fromTime), new Zend_Db_Expr($toTime), new Zend_Db_Expr("'" . $actionOperator . "'"), new Zend_Db_Expr($actionAmount), new Zend_Db_Expr($actionStop), new Zend_Db_Expr($sortOrder), new Zend_Db_Expr("'" . $subActionOperator . "'"), new Zend_Db_Expr($subActionAmount)));
                 if (count($productIds) > 0) {
                     $selectByStore->where('p.entity_id IN (?)', array_keys($productIds));
                 }
                 $selects = $write->selectsByRange('entity_id', $selectByStore, self::RANGE_PRODUCT_STEP);
                 foreach ($selects as $select) {
                     $write->query($write->insertFromSelect($select, $this->getTable('catalogrule/rule_product'), array('website_id', 'customer_group_id', 'product_id', 'rule_id', 'from_time', 'to_time', 'action_operator', 'action_amount', 'action_stop', 'sort_order', 'sub_simple_action', 'sub_discount_amount'), Varien_Db_Adapter_Interface::INSERT_IGNORE));
                 }
             }
         }
     } else {
         if (count($productIds) == 0) {
             Varien_Profiler::start('__MATCH_PRODUCTS__');
             $productIds = $rule->getMatchingProductIds();
             Varien_Profiler::stop('__MATCH_PRODUCTS__');
         }
         $rows = array();
         foreach ($productIds as $productId => $validationByWebsite) {
             foreach ($websiteIds as $websiteId) {
                 foreach ($customerGroupIds as $customerGroupId) {
                     if (empty($validationByWebsite[$websiteId])) {
                         continue;
                     }
                     $rows[] = array('rule_id' => $rule->getId(), 'from_time' => $fromTime, 'to_time' => $toTime, 'website_id' => $websiteId, 'customer_group_id' => $customerGroupId, 'product_id' => $productId, 'action_operator' => $actionOperator, 'action_amount' => $actionAmount, 'action_stop' => $actionStop, 'sort_order' => $sortOrder, 'sub_simple_action' => $subActionOperator, 'sub_discount_amount' => $subActionAmount);
                     if (count($rows) == 1000) {
                         $write->insertMultiple($this->getTable('catalogrule/rule_product'), $rows);
                         $rows = array();
                     }
                 }
             }
         }
         if (!empty($rows)) {
             $write->insertMultiple($this->getTable('catalogrule/rule_product'), $rows);
         }
     }
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:70,代码来源:Rule.php

示例8: _getConfig

 /**
  * Get config model
  *
  * @return Mage_Core_Model_Config_Data
  */
 protected function _getConfig()
 {
     return $this->_factory->getModel('core/config_data');
 }
开发者ID:test3metizsoft,项目名称:test,代码行数:9,代码来源:Notification.php

示例9: _getMetadataCollection

 /**
  * Retrieve metadata collection
  *
  * @return Enterprise_Mview_Model_Resource_Metadata_Collection
  */
 protected function _getMetadataCollection()
 {
     return $this->_factory->getModel('enterprise_mview/metadata')->getCollection();
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:9,代码来源:Cron.php

示例10: applyToProduct

 /**
  * Apply rule to product
  *
  * @param int|Mage_Catalog_Model_Product $product
  * @param array|null $websiteIds
  *
  * @return void
  */
 public function applyToProduct($product, $websiteIds = null)
 {
     if (is_numeric($product)) {
         $product = $this->_factory->getModel('catalog/product')->load($product);
     }
     if (is_null($websiteIds)) {
         $websiteIds = $this->getWebsiteIds();
     }
     $this->getResource()->applyToProduct($this, $product, $websiteIds);
     $this->getResource()->applyAllRules($product);
     $this->_invalidateCache();
 }
开发者ID:okite11,项目名称:frames21,代码行数:20,代码来源:Rule.php

示例11: _executeCategoryRefreshRowAction

 /**
  * Execute category refresh action which refresh url_rewrite index
  *
  * @param Mage_Catalog_Model_Category $category
  */
 protected function _executeCategoryRefreshRowAction(Mage_Catalog_Model_Category $category)
 {
     /** @var $client Enterprise_Mview_Model_Client */
     $client = $this->_factory->getModel('enterprise_mview/client')->init('enterprise_url_rewrite_category');
     $client->execute('enterprise_catalog/index_action_url_rewrite_category_refresh_row', array('category_id' => $category->getId()));
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:11,代码来源:Observer.php


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