本文整理汇总了PHP中Mage_Core_Model_Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Factory类的具体用法?PHP Mage_Core_Model_Factory怎么用?PHP Mage_Core_Model_Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Model_Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __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
示例2: _reindex
protected function _reindex()
{
$factory = new Mage_Core_Model_Factory();
$processes = array();
$indexer = $factory->getSingleton($factory->getIndexClassAlias());
$collection = $indexer->getProcessesCollection();
foreach ($collection as $process) {
if ($process->getIndexer()->isVisible() === false) {
continue;
}
$processes[] = $process;
}
foreach ($processes as $process) {
/* @var $process Mage_Index_Model_Process */
try {
$this->_log("Reindexing " . $process->getIndexerCode());
$process->reindexEverything();
} catch (Exception $e) {
Mage::logException($e);
}
}
}
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:22,代码来源:Observer.php
示例3: _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
示例4: save
/**
* Save value
*
* @return Enterprise_UrlRewrite_Model_System_Config_Backend_MatcherPriority
*/
public function save()
{
if ($this->getOldValue() !== $this->getValue()) {
$matchers = explode('-', $this->getValue());
$priority = 0;
/** @var $configModel Mage_Core_Model_Config */
$configModel = $this->_factory->getSingleton('core/config');
foreach ($matchers as $matcher) {
$priority += 10;
$path = sprintf(Enterprise_UrlRewrite_Model_Url_Rewrite::REWRITE_MATCHERS_PRIORITY_PATH, $matcher);
$configModel->saveConfig($path, $priority);
}
}
return $this;
}
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:20,代码来源:MatcherPriority.php
示例5: _getUrlByRewriteRow
/**
* Get url by rewrite row
*
* @param array $rewriteRow
* @param string $baseUrl
* @param int $storeId
* @return string
* @throws Exception
*/
protected function _getUrlByRewriteRow($rewriteRow, $baseUrl, $storeId)
{
switch ($rewriteRow['entity_type']) {
case Enterprise_Catalog_Model_Product::URL_REWRITE_ENTITY_TYPE:
$url = $baseUrl . $this->_factory->getHelper('enterprise_catalog')->getProductRequestPath($rewriteRow['request_path'], $storeId, $rewriteRow['category_id']);
break;
case Enterprise_Catalog_Model_Category::URL_REWRITE_ENTITY_TYPE:
$url = $baseUrl . $this->_factory->getHelper('enterprise_catalog')->getCategoryRequestPath($rewriteRow['request_path'], $storeId);
break;
default:
throw new Exception('Unknown entity type ' . $rewriteRow['entity_type']);
break;
}
return $url;
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:24,代码来源:Crawler.php
示例6: getProductIds
/**
* Retrieve product Ids
*
* @param Enterprise_TargetRule_Model_Index $object
* @return array
*/
public function getProductIds($object)
{
$adapter = $this->_getReadAdapter();
$select = $adapter->select()->from($this->getMainTable(), 'customer_segment_id')->where('type_id = :type_id')->where('entity_id = :entity_id')->where('store_id = :store_id')->where('customer_group_id = :customer_group_id');
$rotationMode = $this->_factory->getHelper('enterprise_targetrule')->getRotationMode($object->getType());
$segmentsIds = array_merge(array(0), $this->_getSegmentsIdsFromCurrentCustomer());
$bind = array(':type_id' => $object->getType(), ':entity_id' => $object->getProduct()->getEntityId(), ':store_id' => $object->getStoreId(), ':customer_group_id' => $object->getCustomerGroupId());
$segmentsList = $adapter->fetchAll($select, $bind);
$foundSegmentIndexes = array();
foreach ($segmentsList as $segment) {
$foundSegmentIndexes[] = $segment['customer_segment_id'];
}
$productIds = array();
foreach ($segmentsIds as $segmentId) {
if (in_array($segmentId, $foundSegmentIndexes)) {
$productIds = array_merge($productIds, $this->getTypeIndex($object->getType())->loadProductIdsBySegmentId($object, $segmentId));
} else {
$matchedProductIds = $this->_matchProductIdsBySegmentId($object, $segmentId);
$productIds = array_merge($matchedProductIds, $productIds);
$this->getTypeIndex($object->getType())->saveResultForCustomerSegments($object, $segmentId, $matchedProductIds);
$this->saveFlag($object, $segmentId);
}
}
$productIds = array_diff(array_unique($productIds), $object->getExcludeProductIds());
if ($rotationMode == Enterprise_TargetRule_Model_Rule::ROTATION_SHUFFLE) {
shuffle($productIds);
}
return $productIds;
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:35,代码来源:Index.php
示例7: 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
示例8: addExcludeProcess
/**
* Exclude catalogsearch_fulltext indexer
*
* @deprecated since version 1.13.2
* @param Varien_Event_Observer $observer
*/
public function addExcludeProcess(Varien_Event_Observer $observer)
{
$helper = $this->_factory->getHelper('enterprise_catalogsearch');
if (!$helper->isFulltextOn()) {
$observer->getEvent()->getCollection()->addExcludeProcessByCode('catalogsearch_fulltext');
}
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:13,代码来源:Observer.php
示例9: checkDisplaySettings
/**
* Check if tax calculation type and price display settings are compatible
*
* invalid settings if
* Tax Calculation Method Based On 'Total' or 'Row'
* and at least one Display Settings has 'Including and Excluding Tax' value
*
* @param mixed $store
* @return bool
*/
public function checkDisplaySettings($store)
{
if ($this->_factory->getHelper('tax')->getCalculationAgorithm($store) == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
return true;
}
return !$this->displayCartWrappingBothPrices($store) && !$this->displayCartCardBothPrices($store) && !$this->displaySalesWrappingBothPrices($store) && !$this->displaySalesCardBothPrices($store);
}
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:17,代码来源:Data.php
示例10: _toHtml
/**
* ACL validation before html generation
*
* @return string
*/
protected function _toHtml()
{
if ($this->_factory->getSingleton('admin/session')->isAllowed('system/config/tax')) {
return parent::_toHtml();
}
return '';
}
开发者ID:buttasg,项目名称:cowgirlk,代码行数:12,代码来源:Notifications.php
示例11: _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
示例12: 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;
$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:buttasg,项目名称:cowgirlk,代码行数:64,代码来源:Rule.php
示例13: _restoreInitialLocale
/**
* Restore locale of the initial store
*
* @param string $initialLocaleCode
* @param string $initialArea
*
* @return Mage_Core_Model_App_Emulation
*/
protected function _restoreInitialLocale($initialLocaleCode, $initialArea = Mage_Core_Model_App_Area::AREA_ADMINHTML)
{
$currentLocaleCode = $this->_app->getLocale()->getLocaleCode();
if ($currentLocaleCode != $initialLocaleCode) {
$this->_app->getLocale()->setLocaleCode($initialLocaleCode);
$this->_factory->getSingleton('core/translate')->setLocale($initialLocaleCode)->init($initialArea, true);
}
return $this;
}
开发者ID:okite11,项目名称:frames21,代码行数:17,代码来源:Emulation.php
示例14: loadByRequestPath
/**
* Load url rewrite entity by request_path
*
* @param array $paths
* @return Enterprise_UrlRewrite_Model_Url_Rewrite
*/
public function loadByRequestPath($paths)
{
$this->setId(null);
$rewriteRows = $this->_getResource()->getRewrites($paths);
$matchers = $this->_factory->getSingleton('enterprise_urlrewrite/system_config_source_matcherPriority')->getRewriteMatchers();
foreach ($matchers as $matcherIndex) {
$matcher = $this->_factory->getSingleton($this->_factory->getConfig()->getNode(sprintf(self::REWRITE_MATCHERS_MODEL_PATH, $matcherIndex), 'default'));
foreach ($rewriteRows as $row) {
if ($matcher->match($row, $paths['request'])) {
$this->setData($row);
break 2;
}
}
}
$this->_afterLoad();
$this->setOrigData();
$this->_hasDataChanges = false;
return $this;
}
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:25,代码来源:Rewrite.php
示例15: deleteProductCustomRedirects
/**
* Listener for before product delete event. Deletes product custom redirects.
* Needed because of http://bugs.mysql.com/bug.php?id=11472
* @param Varien_Event_Observer $observer
*/
public function deleteProductCustomRedirects(Varien_Event_Observer $observer)
{
if ((string) $this->_app->getConfig()->getNode(Enterprise_UrlRewrite_Model_Index_Observer::XML_PATH_REDIRECT_URL_SUFFIX_UPDATE_ON_SAVE)) {
return;
}
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
/** @var Enterprise_UrlRewrite_Model_Resource_Redirect $redirects */
$redirects = $this->_factory->getResourceModel('enterprise_urlrewrite/redirect');
$redirects->deleteByProductIds(array($product->getId()));
}
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:16,代码来源:Observer.php
示例16: getAllWeee
/**
* Get all FPTs
*
* @return array
*/
public function getAllWeee()
{
$allWeee = array();
$store = $this->getTotal()->getAddress()->getQuote()->getStore();
$helper = $this->_factory->getHelper('weee');
if (!$helper->includeInSubtotal($store)) {
foreach ($this->getTotal()->getAddress()->getCachedItemsAll() as $item) {
foreach ($helper->getApplied($item) as $tax) {
$weeeDiscount = isset($tax['weee_discount']) ? $tax['weee_discount'] : 0;
$title = $tax['title'];
$amount = isset($tax['row_amount']) ? $tax['row_amount'] : 0;
if (array_key_exists($title, $allWeee)) {
$allWeee[$title] = $allWeee[$title] + $amount - $weeeDiscount;
} else {
$allWeee[$title] = $amount - $weeeDiscount;
}
}
}
}
return $allWeee;
}
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:26,代码来源:Tax.php
示例17: getRewriteMatchers
/**
* Fetch rewrite matchers names sorted by priority
*
* @return mixed
*
* @throws Mage_Core_Exception
*/
public function getRewriteMatchers()
{
if (!empty($this->_matchersOrder)) {
return $this->_matchersOrder;
}
$nodes = $this->_factory->getConfig()->getNode(Enterprise_UrlRewrite_Model_Url_Rewrite::REWRITE_MATCHERS_PATH);
foreach ($nodes->children() as $node) {
$priority = (int) $node->priority;
if (isset($this->_matchersOrder[$priority])) {
throw new Mage_Core_Exception($this->_factory->getHelper('enterprise_urlrewrite')->__('URL matcher "%s" has same priority as "%s".', $node->getName(), $this->_matchersOrder[$priority]));
}
$this->_matchersOrder[$priority] = $node->getName();
}
ksort($this->_matchersOrder);
return $this->_matchersOrder;
}
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:23,代码来源:MatcherPriority.php
示例18: getProductRequestPath
/**
* Retrieve product request path
*
* @param string $requestPath
* @param int $storeId
* @param int $categoryId
* @return string
*/
public function getProductRequestPath($requestPath, $storeId, $categoryId = null)
{
if (empty($requestPath)) {
return '';
}
/** @var $helper Mage_Catalog_Helper_Product */
$helper = $this->_factory->getHelper('catalog/product');
$urlSuffix = $helper->getProductUrlSuffix($storeId);
if ($urlSuffix) {
$requestPath .= '.' . $urlSuffix;
}
if (!is_null($categoryId)) {
/** @var $category Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category')->load($categoryId)->setStoreId($storeId);
$categoryUrlKey = $category->getRequestPath();
$requestPath = ltrim($categoryUrlKey . '/' . $requestPath, '/');
}
return $requestPath;
}
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:27,代码来源:Data.php
示例19: _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
示例20: _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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论