コード例 #1
0
ファイル: Collection.php プロジェクト: natxetee/magento2
 /**
  * Add stores to collection
  *
  * @return Mage_Rating_Model_Resource_Rating_Collection
  */
 public function addStoresToCollection()
 {
     if ($this->_app->isSingleStoreMode()) {
         return $this;
     }
     if (!$this->_isCollectionLoaded) {
         return $this;
     }
     $ratingIds = array();
     foreach ($this as $item) {
         $ratingIds[] = $item->getId();
         $item->setStores(array());
     }
     if (!$ratingIds) {
         return $this;
     }
     $adapter = $this->getConnection();
     $inCond = $adapter->prepareSqlCondition('rating_id', array('in' => $ratingIds));
     $this->_select = $adapter->select()->from($this->getTable('rating_store'))->where($inCond);
     $data = $adapter->fetchAll($this->_select);
     if (is_array($data) && count($data) > 0) {
         foreach ($data as $row) {
             $item = $this->getItemById($row['rating_id']);
             $item->setStores(array_merge($item->getStores(), array($row['store_id'])));
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: Switcher.php プロジェクト: nickimproove/magento2
 /**
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->_application->isSingleStoreMode()) {
         return parent::_toHtml();
     }
     return '';
 }
コード例 #3
0
ファイル: Grid.php プロジェクト: nemphys/magento2
 protected function _prepareColumns()
 {
     $this->addColumn('subscriber_id', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('ID'), 'index' => 'subscriber_id'));
     $this->addColumn('email', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Email'), 'index' => 'subscriber_email'));
     $this->addColumn('type', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Type'), 'index' => 'type', 'type' => 'options', 'options' => array(1 => Mage::helper('Mage_Newsletter_Helper_Data')->__('Guest'), 2 => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer'))));
     $this->addColumn('firstname', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer First Name'), 'index' => 'customer_firstname', 'default' => '----'));
     $this->addColumn('lastname', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Customer Last Name'), 'index' => 'customer_lastname', 'default' => '----'));
     $this->addColumn('status', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Status'), 'index' => 'subscriber_status', 'type' => 'options', 'options' => array(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => Mage::helper('Mage_Newsletter_Helper_Data')->__('Not Activated'), Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Subscribed'), Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Unsubscribed'), Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => Mage::helper('Mage_Newsletter_Helper_Data')->__('Unconfirmed'))));
     if (!$this->_app->isSingleStoreMode()) {
         $this->addColumn('website', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Website'), 'index' => 'website_id', 'type' => 'options', 'options' => $this->_getWebsiteOptions()));
         $this->addColumn('group', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Store'), 'index' => 'group_id', 'type' => 'options', 'options' => $this->_getStoreGroupOptions()));
         $this->addColumn('store', array('header' => Mage::helper('Mage_Newsletter_Helper_Data')->__('Store View'), 'index' => 'store_id', 'type' => 'options', 'options' => $this->_getStoreOptions()));
     }
     $this->addExportType('*/*/exportCsv', Mage::helper('Mage_Customer_Helper_Data')->__('CSV'));
     $this->addExportType('*/*/exportXml', Mage::helper('Mage_Customer_Helper_Data')->__('Excel XML'));
     return parent::_prepareColumns();
 }
コード例 #4
0
ファイル: Field.php プロジェクト: nickimproove/magento2
 /**
  * Render scope label
  *
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 protected function _renderScopeLabel(Varien_Data_Form_Element_Abstract $element)
 {
     $html = '<td class="scope-label">';
     if ($element->getScope() && false == $this->_application->isSingleStoreMode()) {
         $html .= $element->getScopeLabel();
     }
     $html .= '</td>';
     return $html;
 }
コード例 #5
0
ファイル: Form.php プロジェクト: natxetee/magento2
 /**
  * Prepare rating edit form
  *
  * @return Mage_Adminhtml_Block_Rating_Edit_Tab_Form
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $fieldset = $form->addFieldset('rating_form', array('legend' => Mage::helper('Mage_Rating_Helper_Data')->__('Rating Title')));
     $fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => Mage::helper('Mage_Rating_Helper_Data')->__('Default Value'), 'class' => 'required-entry', 'required' => true));
     foreach (Mage::getSingleton('Mage_Core_Model_System_Store')->getStoreCollection() as $store) {
         $fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
     }
     if (Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData()) {
         $form->setValues(Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData());
         $data = Mage::getSingleton('Mage_Adminhtml_Model_Session')->getRatingData();
         if (isset($data['rating_codes'])) {
             $this->_setRatingCodes($data['rating_codes']);
         }
         Mage::getSingleton('Mage_Adminhtml_Model_Session')->setRatingData(null);
     } elseif (Mage::registry('rating_data')) {
         $form->setValues(Mage::registry('rating_data')->getData());
         if (Mage::registry('rating_data')->getRatingCodes()) {
             $this->_setRatingCodes(Mage::registry('rating_data')->getRatingCodes());
         }
     }
     if (Mage::registry('rating_data')) {
         $collection = Mage::getModel('Mage_Rating_Model_Rating_Option')->getResourceCollection()->addRatingFilter(Mage::registry('rating_data')->getId())->load();
         $i = 1;
         foreach ($collection->getItems() as $item) {
             $fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
             $i++;
         }
     } else {
         for ($i = 1; $i <= 5; $i++) {
             $fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
         }
     }
     $fieldset = $form->addFieldset('visibility_form', array('legend' => Mage::helper('Mage_Rating_Helper_Data')->__('Rating Visibility')));
     if (!$this->_app->isSingleStoreMode()) {
         $field = $fieldset->addField('stores', 'multiselect', array('label' => Mage::helper('Mage_Rating_Helper_Data')->__('Visible In'), 'name' => 'stores[]', 'values' => Mage::getSingleton('Mage_Core_Model_System_Store')->getStoreValuesForForm()));
         $renderer = $this->getLayout()->createBlock('Mage_Backend_Block_Store_Switcher_Form_Renderer_Fieldset_Element');
         $field->setRenderer($renderer);
         if (Mage::registry('rating_data')) {
             $form->getElement('stores')->setValue(Mage::registry('rating_data')->getStores());
         }
     }
     $fieldset->addField('is_active', 'checkbox', array('label' => Mage::helper('Mage_Rating_Helper_Data')->__('Is Active'), 'name' => 'is_active', 'value' => 1));
     $fieldset->addField('position', 'text', array('label' => Mage::helper('Mage_Rating_Helper_Data')->__('Sort Order'), 'name' => 'position'));
     if (Mage::registry('rating_data')) {
         $form->getElement('position')->setValue(Mage::registry('rating_data')->getPosition());
         $form->getElement('is_active')->setIsChecked(Mage::registry('rating_data')->getIsActive());
     }
     return parent::_prepareForm();
 }
コード例 #6
0
ファイル: Config.php プロジェクト: nemphys/magento2
 /**
  * Checks whether it is possible to show the node
  *
  * @param Varien_Simplexml_Element $node
  * @param string $websiteCode
  * @param string $storeCode
  * @return boolean
  */
 protected function _canShowNode($node, $websiteCode = null, $storeCode = null)
 {
     $showTab = false;
     if ($storeCode) {
         $showTab = (int) $node->show_in_store;
     } elseif ($websiteCode) {
         $showTab = (int) $node->show_in_website;
     } elseif (!empty($node->show_in_default)) {
         $showTab = true;
     }
     $showTab = $showTab || $this->_app->isSingleStoreMode();
     $showTab = $showTab && !($this->_app->isSingleStoreMode() && (int) $node->hide_in_single_store_mode);
     return $showTab;
 }
コード例 #7
0
 /**
  * Set correct scope if isSingleStoreMode = true
  *
  * @param Mage_Backend_Model_Config_Structure_Element_Field $fieldConfig
  * @param Mage_Core_Model_Config_Data $dataObject
  */
 protected function _checkSingleStoreMode(Mage_Backend_Model_Config_Structure_Element_Field $fieldConfig, $dataObject)
 {
     $isSingleStoreMode = $this->_application->isSingleStoreMode();
     if (!$isSingleStoreMode) {
         return;
     }
     if (!$fieldConfig->showInDefault()) {
         $websites = $this->_application->getWebsites();
         $singleStoreWebsite = array_shift($websites);
         $dataObject->setScope('websites');
         $dataObject->setWebsiteCode($singleStoreWebsite->getCode());
         $dataObject->setScopeId($singleStoreWebsite->getId());
     }
 }
コード例 #8
0
ファイル: Config.php プロジェクト: nickimproove/magento2
 /**
  * Set correct scope if isSingleStoreMode = true
  *
  * @param array $fieldConfig
  * @param Mage_Core_Model_Config_Data $dataObject
  */
 protected function _checkSingleStoreMode($fieldConfig, $dataObject)
 {
     $isSingleStoreMode = $this->_application->isSingleStoreMode();
     if (!$isSingleStoreMode) {
         return;
     }
     if (!isset($fieldConfig['showInDefault']) || !(int) $fieldConfig['showInDefault']) {
         $websites = $this->_application->getWebsites();
         $singleStoreWebsite = array_shift($websites);
         $dataObject->setScope('websites');
         $dataObject->setWebsiteCode($singleStoreWebsite->getCode());
         $dataObject->setScopeId($singleStoreWebsite->getId());
     }
 }
コード例 #9
0
ファイル: Structure.php プロジェクト: nickimproove/magento2
 /**
  * Checks whether it is possible to show the node
  *
  * @param mixed $node
  * @param string $websiteCode
  * @param string $storeCode
  * @return boolean
  */
 protected function _canShowNode($node, $websiteCode = null, $storeCode = null)
 {
     $showTab = false;
     if ($storeCode) {
         $showTab = isset($node['showInStore']) ? (int) $node['showInStore'] : false;
     } elseif ($websiteCode) {
         $showTab = isset($node['showInWebsite']) ? (int) $node['showInWebsite'] : false;
     } elseif (isset($node['showInDefault']) && $node['showInDefault']) {
         $showTab = true;
     }
     $showTab = $showTab || $this->_app->isSingleStoreMode();
     $showTab = $showTab && !($this->_app->isSingleStoreMode() && isset($node['hide_in_single_store_mode']) && $node['hide_in_single_store_mode']);
     return $showTab;
 }
コード例 #10
0
ファイル: Rating.php プロジェクト: natxetee/magento2
 /**
  * Return data of rating summary
  *
  * @param Mage_Rating_Model_Rating $object
  * @return array
  */
 protected function _getEntitySummaryData($object)
 {
     $adapter = $this->_getReadAdapter();
     $sumColumn = new Zend_Db_Expr("SUM(rating_vote.{$adapter->quoteIdentifier('percent')})");
     $countColumn = new Zend_Db_Expr("COUNT(*)");
     $select = $adapter->select()->from(array('rating_vote' => $this->getTable('rating_option_vote')), array('entity_pk_value' => 'rating_vote.entity_pk_value', 'sum' => $sumColumn, 'count' => $countColumn))->join(array('review' => $this->getTable('review')), 'rating_vote.review_id=review.review_id', array())->joinLeft(array('review_store' => $this->getTable('review_store')), 'rating_vote.review_id=review_store.review_id', array('review_store.store_id'));
     if (!$this->_app->isSingleStoreMode()) {
         $select->join(array('rating_store' => $this->getTable('rating_store')), 'rating_store.rating_id = rating_vote.rating_id AND rating_store.store_id = review_store.store_id', array());
     }
     $select->join(array('review_status' => $this->getTable('review_status')), 'review.status_id = review_status.status_id', array())->where('review_status.status_code = :status_code')->group('rating_vote.entity_pk_value')->group('review_store.store_id');
     $bind = array(':status_code' => self::RATING_STATUS_APPROVED);
     $entityPkValue = $object->getEntityPkValue();
     if ($entityPkValue) {
         $select->where('rating_vote.entity_pk_value = :pk_value');
         $bind[':pk_value'] = $entityPkValue;
     }
     return $adapter->fetchAll($select, $bind);
 }
コード例 #11
0
ファイル: Collection.php プロジェクト: natxetee/magento2
 /**
  * Add rating info to select
  *
  * @param int $storeId
  * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
  */
 public function addRatingInfo($storeId = null)
 {
     $adapter = $this->getConnection();
     $ratingCodeCond = $adapter->getIfNullSql('title.value', 'rating.rating_code');
     $this->getSelect()->join(array('rating' => $this->getTable('rating')), 'rating.rating_id = main_table.rating_id', array('rating_code'))->joinLeft(array('title' => $this->getTable('rating_title')), $adapter->quoteInto('main_table.rating_id=title.rating_id AND title.store_id = ?', (int) Mage::app()->getStore()->getId()), array('rating_code' => $ratingCodeCond));
     if (!$this->_app->isSingleStoreMode()) {
         if ($storeId == null) {
             $storeId = Mage::app()->getStore()->getId();
         }
         if (is_array($storeId)) {
             $condition = $adapter->prepareSqlCondition('store.store_id', array('in' => $storeId));
         } else {
             $condition = $adapter->quoteInto('store.store_id = ?', $storeId);
         }
         $this->getSelect()->join(array('store' => $this->getTable('rating_store')), 'main_table.rating_id = store.rating_id AND ' . $condition);
     }
     $adapter->fetchAll($this->getSelect());
     return $this;
 }
コード例 #12
0
ファイル: Labels.php プロジェクト: natxetee/magento2
 protected function _prepareForm()
 {
     $rule = Mage::registry('current_promo_quote_rule');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('rule_');
     $fieldset = $form->addFieldset('default_label_fieldset', array('legend' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Default Label')));
     $labels = $rule->getStoreLabels();
     $fieldset->addField('store_default_label', 'text', array('name' => 'store_labels[0]', 'required' => false, 'label' => Mage::helper('Mage_SalesRule_Helper_Data')->__('Default Rule Label for All Store Views'), 'value' => isset($labels[0]) ? $labels[0] : ''));
     if (!$this->_app->isSingleStoreMode()) {
         $fieldset = $this->_createStoreSpecificFieldset($form, $labels);
     }
     if ($rule->isReadonly()) {
         foreach ($fieldset->getElements() as $element) {
             $element->setReadonly(true, true);
         }
     }
     $this->setForm($form);
     return parent::_prepareForm();
 }
コード例 #13
0
 /**
  * Check whether element should be displayed
  *
  * @return bool
  */
 public function isVisible()
 {
     if ($this->_application->isSingleStoreMode()) {
         return !(isset($this->_data['hide_in_single_store_mode']) && $this->_data['hide_in_single_store_mode']);
     }
     $result = false;
     switch ($this->_scope) {
         case Mage_Backend_Model_Config_ScopeDefiner::SCOPE_STORE:
             $result = isset($this->_data['showInStore']) && $this->_data['showInStore'];
             break;
         case Mage_Backend_Model_Config_ScopeDefiner::SCOPE_WEBSITE:
             $result = isset($this->_data['showInWebsite']) && $this->_data['showInWebsite'];
             break;
         case Mage_Backend_Model_Config_ScopeDefiner::SCOPE_DEFAULT:
             $result = isset($this->_data['showInDefault']) && $this->_data['showInDefault'];
             break;
     }
     return $result;
 }
コード例 #14
0
ファイル: Multistore.php プロジェクト: nayanchamp/magento2
 /**
  * Get header css class name
  *
  * @return string
  */
 public function isDisplayed()
 {
     return !$this->_app->isSingleStoreMode();
 }
コード例 #15
0
ファイル: AppTest.php プロジェクト: nemphys/magento2
 /**
  * @magentoAppIsolation enabled
  * @magentoConfigFixture current_store general/single_store_mode/enabled 0
  */
 public function testIsSingleStoreModeWhenDisabled()
 {
     $this->assertFalse($this->_mageModel->isSingleStoreMode());
 }
コード例 #16
0
ファイル: App.php プロジェクト: NatashaOlut/Mage_Test
 public function testIsSingleStoreMode()
 {
     $this->assertNull($this->_model->isSingleStoreMode());
     $this->assertTrue($this->_mageModel->isSingleStoreMode());
 }