本文整理汇总了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;
}
示例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;
}
示例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'));
}
示例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');
}
}
示例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'];
}
}
示例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;
}
示例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);
}
}
}
示例8: _getConfig
/**
* Get config model
*
* @return Mage_Core_Model_Config_Data
*/
protected function _getConfig()
{
return $this->_factory->getModel('core/config_data');
}
示例9: _getMetadataCollection
/**
* Retrieve metadata collection
*
* @return Enterprise_Mview_Model_Resource_Metadata_Collection
*/
protected function _getMetadataCollection()
{
return $this->_factory->getModel('enterprise_mview/metadata')->getCollection();
}
示例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();
}
示例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()));
}