本文整理汇总了PHP中Mage_Core_Model_Website类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Website类的具体用法?PHP Mage_Core_Model_Website怎么用?PHP Mage_Core_Model_Website使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Model_Website类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportSubscribersPerWebsite
/**
* Export subscriber per website.
* @param Mage_Core_Model_Website $website
*
* @return int
*/
public function exportSubscribersPerWebsite(Mage_Core_Model_Website $website)
{
$updated = 0;
$fileHelper = Mage::helper('ddg/file');
$limit = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT);
$subscribers = Mage::getModel('ddg_automation/contact')->getSubscribersToImport($website, $limit);
if (count($subscribers)) {
$subscribersFilename = strtolower($website->getCode() . '_subscribers_' . date('d_m_Y_Hi') . '.csv');
//get mapped storename
$subscriberStorename = Mage::helper('ddg')->getMappedStoreName($website);
//file headers
$fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array('Email', 'emailType', $subscriberStorename));
foreach ($subscribers as $subscriber) {
try {
$email = $subscriber->getEmail();
$subscriber->setSubscriberImported(1)->save();
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$storeName = Mage::app()->getStore($subscriber->getStoreId())->getName();
// save data for subscribers
$fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array($email, 'Html', $storeName));
$updated++;
} catch (Exception $e) {
Mage::logException($e);
}
}
Mage::helper('ddg')->log('Subscriber filename: ' . $subscribersFilename);
//register in queue with importer
Mage::getModel('ddg_automation/importer')->registerQueue(Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_SUBSCRIBERS, '', Dotdigitalgroup_Email_Model_Importer::MODE_BULK, $website->getId(), $subscribersFilename);
}
//add updated number for the website
$this->_countSubscriber += $updated;
return $updated;
}
示例2: _prepareTemporarySelect
/**
* Prepare temporary data
*
* @param Mage_Core_Model_Website $website
* @return Varien_Db_Select
*/
protected function _prepareTemporarySelect(Mage_Core_Model_Website $website)
{
/** @var $catalogFlatHelper Mage_Catalog_Helper_Product_Flat */
$catalogFlatHelper = $this->_factory->getHelper('catalog/product_flat');
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = $this->_factory->getSingleton('eav/config');
$priceAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'price');
//magebrew: get Cost attribute
$costAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
$select = $this->_connection->select()->from(array('rp' => $this->_resource->getTable('catalogrule/rule_product')), array())->joinInner(array('r' => $this->_resource->getTable('catalogrule/rule')), 'r.rule_id = rp.rule_id', array())->where('rp.website_id = ?', $website->getId())->order(array('rp.product_id', 'rp.customer_group_id', 'rp.sort_order', 'rp.rule_product_id'))->joinLeft(array('pg' => $this->_resource->getTable('catalog/product_attribute_group_price')), 'pg.entity_id = rp.product_id AND pg.customer_group_id = rp.customer_group_id' . ' AND pg.website_id = rp.website_id', array())->joinLeft(array('pgd' => $this->_resource->getTable('catalog/product_attribute_group_price')), 'pgd.entity_id = rp.product_id AND pgd.customer_group_id = rp.customer_group_id' . ' AND pgd.website_id = 0', array());
$storeId = $website->getDefaultStore()->getId();
if ($catalogFlatHelper->isEnabled() && $storeId && $catalogFlatHelper->isBuilt($storeId)) {
$select->joinInner(array('p' => $this->_resource->getTable('catalog/product_flat') . '_' . $storeId), 'p.entity_id = rp.product_id', array());
$priceColumn = $this->_connection->getIfNullSql($this->_connection->getIfNullSql('pg.value', 'pgd.value'), 'p.price');
//magebrew: Cost column select for Flat catalog
$costColumn = $this->_connection->getIfNullSql('p.cost', 0);
} else {
$select->joinInner(array('pd' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))), 'pd.entity_id = rp.product_id AND pd.store_id = 0 AND pd.attribute_id = ' . $priceAttribute->getId(), array())->joinLeft(array('p' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))), 'p.entity_id = rp.product_id AND p.store_id = ' . $storeId . ' AND p.attribute_id = pd.attribute_id', array())->joinLeft(array('pc' => $this->_resource->getTable(array('catalog/product', $costAttribute->getBackendType()))), 'pc.entity_id = rp.product_id AND pc.store_id = 0 AND pc.attribute_id = ' . $costAttribute->getId(), array());
$priceColumn = $this->_connection->getIfNullSql($this->_connection->getIfNullSql('pg.value', 'pgd.value'), $this->_connection->getIfNullSql('p.value', 'pd.value'));
//magebrew: Cost column select for Eav catalog
$costColumn = $this->_connection->getIfNullSql('pc.value', 0);
}
$select->columns(array('grouped_id' => $this->_connection->getConcatSql(array('rp.product_id', 'rp.customer_group_id'), '-'), 'product_id' => 'rp.product_id', 'customer_group_id' => 'rp.customer_group_id', 'from_date' => 'r.from_date', 'to_date' => 'r.to_date', 'action_amount' => 'rp.action_amount', 'action_operator' => 'rp.action_operator', 'action_stop' => 'rp.action_stop', 'sort_order' => 'rp.sort_order', 'price' => $priceColumn, 'cost' => $costColumn, 'rule_product_id' => 'rp.rule_product_id', 'from_time' => 'rp.from_time', 'to_time' => 'rp.to_time'));
return $select;
}
示例3: _getCollection
/**
* filter $collection by the cutoff date.
* @param string $cutoffDate
* @param Mage_Core_Model_Website $website
* @return Varien_Data_Collection_Db
*/
protected function _getCollection($cutoffDate, Mage_Core_Model_Website $website)
{
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToSelect('entity_id');
if ($cutoffDate) {
$collection->addFieldToFilter('updated_at', array('gteq' => $cutoffDate));
}
$collection->addWebsiteFilter(array($website->getId()));
return $collection;
}
示例4: _getChangedStoresForWebsite
/**
* @param Mage_Core_Model_Website $website
* @return array
*/
protected function _getChangedStoresForWebsite($website)
{
$changedStores = array();
foreach ($website->getStores() as $store) {
/** @var Mage_Core_Model_Store $store */
if ($this->_isValueChanged($store, $website)) {
$changedStores[Mage::helper('scopehint')->__('Store View: %s', $this->_getFullStoreName($store))] = $this->_getReadableConfigValue($store);
}
}
return $changedStores;
}
示例5: _saveWebsiteConfigItems
private function _saveWebsiteConfigItems(array $configs, Mage_Core_Model_Website $website)
{
try {
if (!$website->getId()) {
throw new Exception($this->__('Website does not exist'));
}
if (!empty($configs)) {
foreach ($configs as $config) {
if (isset($config['encrypted']) && $config['encrypted'] == 1) {
$config['value'] = Mage::helper('core')->encrypt($config['value']);
}
// Save config
$this->_checkAndSaveConfig($config['path'], $config['value'], 'websites', $website->getId(), $website->getCode());
}
}
} catch (Exception $e) {
$this->log($e->getMessage());
}
}
示例6: _addWebsiteFieldset
/**
* Method add website fieldset to the form.
* @param Mage_Core_Model_Website $website
*/
private function _addWebsiteFieldset($website, $form)
{
$prefixWeb = 'website-' . $website->getCode();
/* make fieldset */
$layoutFieldset = $form->addFieldset($prefixWeb . '_fieldset', array('legend' => Mage::helper('mturbo')->__($website->getName() . ' settings'), 'class' => 'fieldset'));
/* add extra user control */
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
/* indicator whether website is enabled */
$layoutFieldset->addField($prefixWeb . '-enabled', 'select', array('name' => $prefixWeb . '-enabled', 'label' => Mage::helper('mturbo')->__('Enable website') . ':', 'value' => '1', 'options' => array(0 => Mage::helper('mturbo')->__('No'), 1 => Mage::helper('mturbo')->__('Yes'))));
/* add field for turbopath */
$layoutFieldset->addField($prefixWeb . '-base_dir', 'text', array('name' => $prefixWeb . '-base_dir', 'value' => Mage::getBaseDir(), 'label' => Mage::helper('mturbo')->__('Base directory') . ':'));
/* add field for server name */
$layoutFieldset->addField($prefixWeb . '-server_name', 'text', array('name' => $prefixWeb . '-server_name', 'value' => Mage::helper('mturbo/website')->getServerName($website->getDefaultStore()->getCode()), 'label' => Mage::helper('mturbo')->__('Server name') . ':'));
/* every store has one select determines whether enabled is */
foreach ($website->getStores() as $store) {
if ($store->getIsActive()) {
$layoutFieldset->addField($prefixWeb . '-store-' . $store->getCode(), 'select', array('name' => $prefixWeb . '-store-' . $store->getCode(), 'label' => $store->getGroup()->getName() . '<br />' . $store->getName(), 'value' => '1', 'options' => array(0 => Mage::helper('mturbo')->__('No'), 1 => Mage::helper('mturbo')->__('Yes'))));
}
}
}
示例7: _addWebsiteFieldset
/**
* Method add website fieldset to the form.
* @param Mage_Core_Model_Website $website
*/
private function _addWebsiteFieldset($website)
{
$prefixWeb = 'website-' . $website->getCode();
/* make fieldset */
$layoutFieldset = $this->form->addFieldset($prefixWeb . '_fieldset', array('legend' => $this->getMyHelper()->__($website->getName() . ' settings'), 'class' => 'fieldset'));
/* add extra user control */
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
/* indicator whether website is enabled */
$layoutFieldset->addField($prefixWeb . '-enabled', 'select', array('name' => $prefixWeb . '-enabled', 'label' => $this->getMyHelper()->__('Enable website') . ':', 'options' => array(0 => $this->getMyHelper()->__('No'), 1 => $this->getMyHelper()->__('Yes'))));
/* add field for base dir */
$layoutFieldset->addField($prefixWeb . '-base_dir', 'text', array('name' => $prefixWeb . '-base_dir', 'label' => $this->getMyHelper()->__('Base directory') . ':'));
/* add field for server name */
$layoutFieldset->addField($prefixWeb . '-server_name', 'text', array('name' => $prefixWeb . '-server_name', 'label' => $this->getMyHelper()->__('Server name') . ':'));
$layoutFieldset->addField($prefixWeb . '_dec1', 'html_element', array('label' => '<h4>' . $this->getMyHelper()->__('Enable/Disable Storeview') . '</h4>', 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
/* every store has one select determines whether enabled is */
foreach ($website->getStores() as $store) {
if ($store->getIsActive()) {
$layoutFieldset->addField($prefixWeb . '-store-' . $store->getCode(), 'select', array('name' => $prefixWeb . '-store-' . $store->getCode(), 'label' => $store->getGroup()->getName() . '<br />' . $store->getName(), 'options' => array(0 => $this->getMyHelper()->__('No'), 1 => $this->getMyHelper()->__('Yes'))));
}
}
$layoutFieldset->addField($prefixWeb . '_dec2', 'html_element', array('label' => '<h4>' . $this->getMyHelper()->__('Htaccess settings') . '</h4>', 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
/* get htaccess state and set color by it */
$htaccess = Mage::getModel('mturbo/htaccess')->setWebsiteCode($website->getCode());
$state = '';
$pathToHtaccess = $htaccess->getPathToBaseHtaccess();
$color = Mage::helper('mturbo/functions')->get_file_state($pathToHtaccess, $state, 'ew') ? 'green' : 'red';
$layoutFieldset->addField($prefixWeb . '_dec3', 'html_element', array('label' => $this->getMyHelper()->__('File .htaccess path'), 'code' => '<span>' . $pathToHtaccess . '</span>'));
$edit = $htaccess->isEditedByMTurbo() ? 'yes' : 'no';
$layoutFieldset->addField($prefixWeb . '_dec5', 'html_element', array('label' => $this->getMyHelper()->__('Edited by MTurbo'), 'code' => '<span><b>' . $this->getMyHelper()->__($edit) . '</b></span>'));
$layoutFieldset->addField($prefixWeb . '_dec4', 'html_element', array('label' => $this->getMyHelper()->__('File .htaccess state'), 'code' => '<span style="color:' . $color . '">' . $this->getMyHelper()->__($state) . '</span>'));
/* button 'rebuild' show only if htaccess is ready */
if ($color == 'green') {
$layoutFieldset->addField($prefixWeb . '_htaccess_button', 'widget_button', array('name' => $prefixWeb . '_htaccess_button', 'label' => $this->getMyHelper()->__('Rebuild .htaccess for this website'), 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/htaccessbuild', array('websitecode' => $website->getCode())) . "')"));
}
$layoutFieldset->addField($prefixWeb . '_urllist_button', 'widget_button', array('name' => $prefixWeb . '_urllist_button', 'label' => $this->getMyHelper()->__('Generate URL list for this website'), 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/generateurllist', array('websitecode' => $website->getCode())) . "')"));
}
示例8: clearWebsiteCache
/**
* Unset website by id from app cache
*
* @param null|bool|int|string|Mage_Core_Model_Website $id
* @return void
*/
public function clearWebsiteCache($id = null)
{
if (is_null($id)) {
$id = $this->getStore()->getWebsiteId();
} elseif ($id instanceof Mage_Core_Model_Website) {
$id = $id->getId();
} elseif ($id === true) {
$id = $this->_website->getId();
}
if (!empty($this->_websites[$id])) {
$website = $this->_websites[$id];
unset($this->_websites[$website->getWebsiteId()]);
unset($this->_websites[$website->getCode()]);
}
}
示例9: _calculateSpecialPrice
/**
* Apply special price
*
* @param float $finalPrice
* @param array $priceData
* @param Mage_Core_Model_Website $website
* @return float
*/
public function _calculateSpecialPrice($finalPrice, array $priceData, Mage_Core_Model_Website $website)
{
$store = $website->getDefaultStore();
$specialPrice = $priceData['special_price'];
if (!is_null($specialPrice) && $specialPrice != false) {
if (Mage::app()->getLocale()->isStoreDateInInterval($store, $priceData['special_from_date'], $priceData['special_to_date'])) {
$specialPrice = $finalPrice * $specialPrice / 100;
$finalPrice = min($finalPrice, $specialPrice);
}
}
return $finalPrice;
}
示例10: setWebsite
/**
* Set Website scope
*
* @param Mage_Core_Model_Website|int $website
* @return Mage_Eav_Model_Resource_Attribute_Collection
*/
public function setWebsite($website)
{
$this->_website = Mage::app()->getWebsite($website);
$this->addBindParam('scope_website_id', $this->_website->getId());
return $this;
}
示例11: updateDataFields
/**
* update data fields
*
* @param $email
* @param Mage_Core_Model_Website $website
* @param $storeName
*/
public function updateDataFields($email, Mage_Core_Model_Website $website, $storeName)
{
$data = array();
if ($store_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)) {
$data[] = array('Key' => $store_name, 'Value' => $storeName);
}
if ($website_name = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)) {
$data[] = array('Key' => $website_name, 'Value' => $website->getName());
}
if (!empty($data)) {
//update data fields
$client = $this->getWebsiteApiClient($website);
$client->updateContactDatafieldsByEmail($email, $data);
}
}
示例12: _removeOldIndexData
/**
* Remove old index data
*
* @param Mage_Core_Model_Website $website
*/
protected function _removeOldIndexData(Mage_Core_Model_Website $website)
{
$this->_connection->delete($this->_resource->getTable('catalogrule/rule_product_price'), array('website_id = ?' => $website->getId()));
}
示例13: _initCurrentStore
/**
* Initialize currently ran store
*
* @param string $scopeCode code of default scope (website/store_group/store code)
* @param string $scopeType type of default scope (website/group/store)
* @return unknown_type
*/
protected function _initCurrentStore($scopeCode, $scopeType)
{
Varien_Profiler::start('mage::app::init::stores');
$this->_initStores();
Varien_Profiler::stop('mage::app::init::stores');
if (empty($scopeCode) && !is_null($this->_website)) {
$scopeCode = $this->_website->getCode();
$scopeType = 'website';
}
switch ($scopeType) {
case 'store':
$this->_currentStore = $scopeCode;
break;
case 'group':
$this->_currentStore = $this->_getStoreByGroup($scopeCode);
break;
case 'website':
$this->_currentStore = $this->_getStoreByWebsite($scopeCode);
break;
default:
$this->throwStoreException();
}
if (!empty($this->_currentStore)) {
$this->_checkCookieStore($scopeType);
$this->_checkGetStore($scopeType);
}
$this->_useSessionInUrl = $this->getStore()->getConfig(Mage_Core_Model_Session_Abstract::XML_PATH_USE_FRONTEND_SID);
return $this;
}
示例14: _initCurrentStore
/**
* Initialize currently ran store
*
* @param string $scopeCode code of default scope (website/store_group/store code)
* @param string $scopeType type of default scope (website/group/store)
* @return unknown_type
*/
protected function _initCurrentStore($scopeCode, $scopeType)
{
Varien_Profiler::start('mage::app::init::stores');
$this->_initStores();
Varien_Profiler::stop('mage::app::init::stores');
if (empty($scopeCode) && !is_null($this->_website)) {
$scopeCode = $this->_website->getCode();
$scopeType = 'website';
}
switch ($scopeType) {
case 'store':
$this->_currentStore = $scopeCode;
break;
case 'group':
$this->_currentStore = $this->_getStoreByGroup($scopeCode);
break;
case 'website':
$this->_currentStore = $this->_getStoreByWebsite($scopeCode);
break;
default:
$this->throwStoreException();
}
if (!empty($this->_currentStore)) {
$this->_checkCookieStore($scopeType);
$this->_checkGetStore($scopeType);
}
return $this;
}
示例15: send
/**
* Send customer email
*
* @return bool
*/
public function send()
{
if (is_null($this->_website) || is_null($this->_customer)) {
return false;
}
if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
return false;
}
if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
return false;
}
$store = $this->_website->getDefaultStore();
$storeId = $store->getId();
if ($this->_type == 'price' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId)) {
return false;
} elseif ($this->_type == 'stock' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId)) {
return false;
}
// set design parameters, required for email (remember current)
$currentDesign = Mage::getDesign()->setAllGetOld(array('store' => $storeId, 'area' => 'frontend', 'package' => Mage::getStoreConfig('design/package/name', $storeId)));
Mage::app()->getLocale()->emulate($storeId);
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
if ($this->_type == 'price') {
$this->_getPriceBlock()->setStore($store)->reset();
foreach ($this->_priceProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getPriceBlock()->addProduct($product);
}
$block = $this->_getPriceBlock()->toHtml();
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId);
} elseif ($this->_type == 'stock') {
$this->_getStockBlock()->setStore($store)->reset();
foreach ($this->_stockProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getStockBlock()->addProduct($product);
}
$block = $this->_getStockBlock()->toHtml();
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId);
} else {
Mage::app()->getLocale()->revert();
return false;
}
Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($templateId, Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId), $this->_customer->getEmail(), $this->_customer->getName(), array('customerName' => $this->_customer->getName(), 'alertGrid' => $block));
$translate->setTranslateInline(true);
// revert current design
Mage::getDesign()->setAllGetOld($currentDesign);
Mage::app()->getLocale()->revert();
return true;
}