コード例 #1
0
ファイル: Collection.php プロジェクト: jpbender/mage_virtual
 public function joinCustomers()
 {
     $customer = Mage::getResourceSingleton('customer/customer');
     //TODO: add full name logic
     $firstnameAttr = $customer->getAttribute('firstname');
     $firstnameAttrId = $firstnameAttr->getAttributeId();
     $firstnameTable = $firstnameAttr->getBackend()->getTable();
     if ($firstnameAttr->getBackend()->isStatic()) {
         $firstnameField = 'firstname';
         $attrCondition = '';
     } else {
         $firstnameField = 'value';
         $attrCondition = ' AND _table_customer_firstname.attribute_id = ' . $firstnameAttrId;
     }
     $this->getSelect()->joinInner(array('_table_customer_firstname' => $firstnameTable), '_table_customer_firstname.entity_id=detail.customer_id' . $attrCondition, array());
     $lastnameAttr = $customer->getAttribute('lastname');
     $lastnameAttrId = $lastnameAttr->getAttributeId();
     $lastnameTable = $lastnameAttr->getBackend()->getTable();
     if ($lastnameAttr->getBackend()->isStatic()) {
         $lastnameField = 'lastname';
         $attrCondition = '';
     } else {
         $lastnameField = 'value';
         $attrCondition = ' AND _table_customer_lastname.attribute_id = ' . $lastnameAttrId;
     }
     $this->getSelect()->joinInner(array('_table_customer_lastname' => $lastnameTable), '_table_customer_lastname.entity_id=detail.customer_id' . $attrCondition, array())->columns(array('customer_name' => "CONCAT(_table_customer_firstname.{$firstnameField}, ' ', _table_customer_lastname.{$lastnameField})", 'review_cnt' => "COUNT(main_table.review_id)"))->group('detail.customer_id');
     return $this;
 }
コード例 #2
0
ファイル: Main.php プロジェクト: xiaoguizhidao/BumblebeeSite
 /**
  * Preparation of current form
  *
  * @return Inic_Faq_Block_Admin_Edit_Tab_Main Self
  */
 protected function _prepareForm()
 {
     $model = Mage::registry('faq');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('faq_');
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('faq')->__('General information'), 'class' => 'fieldset-wide'));
     if ($model->getFaqId()) {
         $fieldset->addField('faq_id', 'hidden', array('name' => 'faq_id'));
     }
     $approveInfo = $fieldset->addField('question', 'text', array('name' => 'question', 'label' => Mage::helper('faq')->__('FAQ item question'), 'title' => Mage::helper('faq')->__('FAQ item question'), 'required' => true));
     /**
      * Check is single store mode
      */
     if (!Mage::app()->isSingleStoreMode()) {
         $store_id = $fieldset->addField('store_id', 'multiselect', array('name' => 'store_id[]', 'label' => Mage::helper('faq')->__('Store view'), 'title' => Mage::helper('faq')->__('Store view'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
     } else {
         $store_id = $fieldset->addField('store_id', 'hidden', array('name' => 'store_id[]', 'value' => Mage::app()->getStore(true)->getId()));
         $model->setStoreId(Mage::app()->getStore(true)->getId());
     }
     $status = $fieldset->addField('is_active', 'select', array('label' => Mage::helper('faq')->__('Status'), 'title' => Mage::helper('faq')->__('Item status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('faq')->__('Enabled'), '0' => Mage::helper('faq')->__('Disabled'))));
     $fieldset->addField('is_most_frequent', 'select', array('label' => Mage::helper('faq')->__('Is Most Frequent'), 'title' => Mage::helper('faq')->__('Is Most Frequent'), 'name' => 'is_most_frequent', 'required' => true, 'options' => array('1' => Mage::helper('faq')->__('Yes'), '0' => Mage::helper('faq')->__('No'))));
     $category_id = $fieldset->addField('category_id', 'multiselect', array('label' => Mage::helper('faq')->__('Category'), 'title' => Mage::helper('faq')->__('Category'), 'name' => 'category_id[]', 'required' => false, 'values' => Mage::getResourceSingleton('faq/category_collection')->toOptionArray()));
     $fieldset->addField('answer', 'editor', array('name' => 'answer', 'label' => Mage::helper('faq')->__('Content'), 'title' => Mage::helper('faq')->__('Content'), 'style' => 'height:36em;', 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(), 'state' => 'html', 'required' => true));
     $data = $model->getData();
     if (!count($data)) {
         $data['store_id'] = 0;
     }
     $form->setValues($data);
     $this->setForm($form);
     $cat_id = $model->getData('category_id');
     $selected = $cat_id ? $cat_id : "";
     $this->setChild('form_after', $this->getLayout()->createBlock('faq/adminhtml_widget_form_element_selectdependence')->addFieldMap($store_id->getHtmlId(), $category_id->getHtmlId(), $selected));
     return parent::_prepareForm();
 }
コード例 #3
0
 /**
  * Prepare cart items URLs
  *
  * @deprecated after 1.7.0.2
  */
 public function prepareItemUrls()
 {
     $products = array();
     /* @var $item Mage_Sales_Model_Quote_Item */
     foreach ($this->getItems() as $item) {
         $product = $item->getProduct();
         $option = $item->getOptionByCode('product_type');
         if ($option) {
             $product = $option->getProduct();
         }
         if ($item->getStoreId() != Mage::app()->getStore()->getId() && !$item->getRedirectUrl() && !$product->isVisibleInSiteVisibility()) {
             $products[$product->getId()] = $item->getStoreId();
         }
     }
     if ($products) {
         $products = Mage::getResourceSingleton('catalog/url')->getRewriteByProductStore($products);
         foreach ($this->getItems() as $item) {
             $product = $item->getProduct();
             $option = $item->getOptionByCode('product_type');
             if ($option) {
                 $product = $option->getProduct();
             }
             if (isset($products[$product->getId()])) {
                 $object = new Varien_Object($products[$product->getId()]);
                 $item->getProduct()->setUrlDataObject($object);
             }
         }
     }
 }
コード例 #4
0
ファイル: Upsell.php プロジェクト: EliasZ/Ho_SimpleBundle
 protected function _prepareData()
 {
     $product = Mage::registry('product');
     /* @var $product Mage_Catalog_Model_Product */
     $this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter();
     if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
         Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection, Mage::getSingleton('checkout/session')->getQuoteId());
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
     //        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
     if ($this->getItemLimit('upsell') > 0) {
         $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
     }
     if ($this->getData('show_bundles')) {
         $this->_itemCollection->addAttributeToFilter('type_id', array('eq' => 'bundle'));
         //            /* Updating collection with desired items */
         //            Mage::dispatchEvent('catalog_product_upsell', array(
         //                'product'       => $product,
         //                'collection'    => $this->_itemCollection,
         //                'limit'         => $this->getItemLimit()
         //            ));
     } else {
         $this->_itemCollection->addAttributeToFilter('type_id', array('neq' => 'bundle'));
     }
     $this->_itemCollection->load();
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
コード例 #5
0
 public function afterSave($object)
 {
     $generalStoreId = $object->getStoreId();
     $periods = $object->getData($this->getAttribute()->getName());
     Mage::getResourceSingleton('payperrentals/reservationprices')->deleteByEntityId($object->getId(), $generalStoreId);
     if (is_null($periods)) {
         return $this;
     }
     if (is_array($periods)) {
         foreach ($periods as $k => $period) {
             if (!is_numeric($k)) {
                 continue;
             }
             if (array_key_exists('use_default_value', $period) && $period['use_default_value']) {
                 $storeId = $generalStoreId;
                 $checkCollection = Mage::getModel('payperrentals/reservationprices')->getCollection()->addFieldToFilter('entity_id', $object->getId())->addFieldToFilter('store_id', $storeId)->addFieldToFilter('numberof', $period['numberof'])->addFieldToFilter('ptype', $period['ptype'])->addFieldToFilter('price', $period['price'])->addFieldToFilter('reservationpricesdates_id', $period['reservationpricesdates_id'])->addFieldToFilter('qty_start', $period['qtystart'])->addFieldToFilter('qty_end', $period['qtyend'])->addFieldToFilter('customers_group', $period['custgroup'])->addFieldToFilter('ptypeadditional', $period['priceadditional'])->addFieldToFilter('ptypeadditional', $period['ptypeadditional'])->addFieldToFilter('damage_waiver', $period['damage_waiver']);
                 if (count($checkCollection)) {
                     continue;
                 }
             } else {
                 $storeId = $generalStoreId;
             }
             $myRes = Mage::getModel('payperrentals/reservationprices')->setEntityId($object->getId())->setStoreId($storeId)->setNumberof($period['numberof'])->setPtype($period['ptype'])->setPrice($period['price'])->setQtyStart($period['qtystart'])->setQtyEnd($period['qtyend'])->setCustomersGroup($period['custgroup'])->setPtypeadditional($period['ptypeadditional'])->setPriceadditional($period['priceadditional'])->setReservationpricesdatesId($period['reservationpricesdates_id']);
             $myRes->save();
         }
     } elseif ($object->getIsDuplicate() == true) {
         $priceCollection = Mage::getModel('payperrentals/reservationprices')->getCollection()->addFieldToFilter('entity_id', $object->getOriginalId());
         foreach ($priceCollection as $priceItem) {
             $priceItem->setId(null)->setEntityId($object->getId())->save();
         }
     }
     return $this;
 }
コード例 #6
0
 /**
  * Join customers
  *
  * @return Mage_Reports_Model_Resource_Review_Customer_Collection
  */
 public function joinCustomers()
 {
     /**
      * Allow to use analytic function to result select
      */
     $this->_useAnalyticFunction = true;
     /** @var $adapter Varien_Db_Adapter_Interface */
     $adapter = $this->getConnection();
     /** @var $customer Mage_Customer_Model_Resource_Customer */
     $customer = Mage::getResourceSingleton('customer/customer');
     /** @var $firstnameAttr Mage_Eav_Model_Entity_Attribute */
     $firstnameAttr = $customer->getAttribute('firstname');
     /** @var $lastnameAttr Mage_Eav_Model_Entity_Attribute */
     $lastnameAttr = $customer->getAttribute('lastname');
     $firstnameCondition = array('table_customer_firstname.entity_id = detail.customer_id');
     if ($firstnameAttr->getBackend()->isStatic()) {
         $firstnameField = 'firstname';
     } else {
         $firstnameField = 'value';
         $firstnameCondition[] = $adapter->quoteInto('table_customer_firstname.attribute_id = ?', (int) $firstnameAttr->getAttributeId());
     }
     $this->getSelect()->joinInner(array('table_customer_firstname' => $firstnameAttr->getBackend()->getTable()), implode(' AND ', $firstnameCondition), array());
     $lastnameCondition = array('table_customer_lastname.entity_id = detail.customer_id');
     if ($lastnameAttr->getBackend()->isStatic()) {
         $lastnameField = 'lastname';
     } else {
         $lastnameField = 'value';
         $lastnameCondition[] = $adapter->quoteInto('table_customer_lastname.attribute_id = ?', (int) $lastnameAttr->getAttributeId());
     }
     //Prepare fullname field result
     $customerFullname = $adapter->getConcatSql(array("table_customer_firstname.{$firstnameField}", "table_customer_lastname.{$lastnameField}"), ' ');
     $this->getSelect()->reset(Zend_Db_Select::COLUMNS)->joinInner(array('table_customer_lastname' => $lastnameAttr->getBackend()->getTable()), implode(' AND ', $lastnameCondition), array())->columns(array('customer_id' => 'detail.customer_id', 'customer_name' => $customerFullname, 'review_cnt' => 'COUNT(main_table.review_id)'))->group('detail.customer_id');
     return $this;
 }
コード例 #7
0
ファイル: Catalog.php プロジェクト: hazaeluz/magento_connect
 public function getResource()
 {
     if (!$this->_resource) {
         $this->_resource = Mage::getResourceSingleton('catalog_entity/convert');
     }
     return $this->_resource;
 }
コード例 #8
0
 protected function _prepareData()
 {
     // Default back to core functionality
     if (!Mage::helper('predictions')->canOverrideRelatedProducts()) {
         return parent::_prepareData();
     }
     /* Retrieve related product ids here. */
     $predictionHelper = Mage::helper('predictions');
     $cookieId = array($predictionHelper->getCurrentUserUniqueId());
     $customer = Mage::getSingleton('customer/session');
     if ($customer->isLoggedIn()) {
         $cookieId[] = $customer->getId();
     }
     $recommendationCollection = Mage::getModel('predictions/recommendation')->getCollection()->addFieldToFilter('cookie_id', array('in' => $cookieId));
     // [todo] - Add a collection limit thorugh configuration
     // [todo] - Remove when refactored to single id
     //        if (Mage::getSingleton('customer/session')->isLoggedIn()) {
     //            $customerData = Mage::getSingleton('customer/session')->getCustomer();
     //            $recommendationCollection->addFieldToFilter('customer_id', array('eq' => $customerData->getId()));
     //        }
     $predictionioIds = $recommendationCollection->getColumnValues('product_id');
     // [review] - Review the logic for loading the product collection for this block
     $this->_itemCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('entity_id', array('in' => $predictionioIds))->addAttributeToSelect('required_options')->addStoreFilter();
     if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
         Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection, Mage::getSingleton('checkout/session')->getQuoteId());
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
     $this->_itemCollection->load();
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
コード例 #9
0
 protected function _getCollection()
 {
     if (is_null($this->_resourceModel)) {
         $this->_resourceModel = Mage::getResourceSingleton($this->_resourceClass);
     }
     return $this->_resourceModel;
 }
コード例 #10
0
ファイル: Category.php プロジェクト: xiaoguizhidao/mydigibits
 /**
  * Enter description here...
  *
  * @return EM_Blog_Model_Resource_Category_Tree
  */
 public function getTreeModelInstance()
 {
     if (is_null($this->_treeModel)) {
         $this->_treeModel = Mage::getResourceSingleton('blog/category_tree');
     }
     return $this->_treeModel;
 }
コード例 #11
0
ファイル: Configurable.php プロジェクト: buttasg/cowgirlk
 /**
  * Save configurable product relations
  *
  * @param Mage_Catalog_Model_Product|int $mainProduct the parent id
  * @param array $productIds the children id array
  * @return Mage_Catalog_Model_Resource_Product_Type_Configurable
  */
 public function saveProducts($mainProduct, $productIds)
 {
     $isProductInstance = false;
     if ($mainProduct instanceof Mage_Catalog_Model_Product) {
         $mainProductId = $mainProduct->getId();
         $isProductInstance = true;
     } else {
         $mainProductId = $mainProduct;
     }
     $old = $mainProduct->getTypeInstance()->getUsedProductIds();
     $insert = array_diff($productIds, $old);
     $delete = array_diff($old, $productIds);
     if ((!empty($insert) || !empty($delete)) && $isProductInstance) {
         $mainProduct->setIsRelationsChanged(true);
     }
     if (!empty($delete)) {
         $where = array('parent_id = ?' => $mainProductId, 'product_id IN(?)' => $delete);
         $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
     }
     if (!empty($insert)) {
         $data = array();
         foreach ($insert as $childId) {
             $data[] = array('product_id' => (int) $childId, 'parent_id' => (int) $mainProductId);
         }
         $this->_getWriteAdapter()->insertMultiple($this->getMainTable(), $data);
     }
     // configurable product relations should be added to relation table
     Mage::getResourceSingleton('catalog/product_relation')->processRelations($mainProductId, $productIds);
     return $this;
 }
コード例 #12
0
 /**
  * Prepare main form
  *
  * @return MatheusGontijo_EasyShippingRules_Block_Adminhtml_Easyshippingrules_Custommethod_Edit_Tab_Main
  */
 protected function _prepareForm()
 {
     $model = Mage::registry('current_easyshippingrules_custom_method');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('custom_method_');
     $form->setFieldNameSuffix('custom_method');
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('General Information')));
     if ($model->getId()) {
         $fieldset->addField('easyshippingrules_custom_method_id', 'hidden', array('name' => 'easyshippingrules_custom_method_id'));
     }
     $carrierValues = Mage::getResourceSingleton('easyshippingrules/carrier_collection')->toOptionArray();
     array_unshift($carrierValues, array('label' => '', 'value' => ''));
     $fieldset->addField('easyshippingrules_carrier_id', 'select', array('name' => 'easyshippingrules_carrier_id', 'label' => $this->__('Carrier'), 'title' => $this->__('Carrier'), 'values' => $carrierValues));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true));
     $fieldset->addField('is_active', 'select', array('label' => Mage::helper('adminhtml')->__('Status'), 'title' => Mage::helper('adminhtml')->__('Status'), 'name' => 'is_active', 'required' => true, 'options' => Mage::getModel('easyshippingrules/system_status')->toArray()));
     if (!$model->getId()) {
         $model->setIsActive(1);
     }
     /**
      * Check is single store mode
      */
     if (!Mage::app()->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('adminhtml')->__('Store View'), 'title' => Mage::helper('adminhtml')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
         if (!$model->getId()) {
             $model->setData('store_id', Mage_Core_Model_App::ADMIN_STORE_ID);
         }
         $field->setRenderer($this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'));
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId()));
         $model->setStoreId(Mage::app()->getStore(true)->getId());
     }
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
コード例 #13
0
ファイル: Filter.php プロジェクト: cewolf2002/magento
 /**
  * Generate widget
  *
  * @param array $construction
  * @return string
  */
 public function widgetDirective($construction)
 {
     $params = $this->_getIncludeParameters($construction[2]);
     // Determine what name block should have in layout
     $name = null;
     if (isset($params['name'])) {
         $name = $params['name'];
     }
     // validate required parameter type or id
     if (!empty($params['type'])) {
         $type = $params['type'];
     } elseif (!empty($params['id'])) {
         $preconfigured = Mage::getResourceSingleton('widget/widget')->loadPreconfiguredWidget($params['id']);
         $type = $preconfigured['widget_type'];
         $params = $preconfigured['parameters'];
     } else {
         return '';
     }
     // we have no other way to avoid fatal errors for type like 'cms/widget__link', '_cms/widget_link' etc.
     $xml = Mage::getSingleton('widget/widget')->getXmlElementByType($type);
     if ($xml === null) {
         return '';
     }
     // define widget block and check the type is instance of Widget Interface
     $widget = Mage::app()->getLayout()->createBlock($type, $name, $params);
     if (!$widget instanceof Mage_Widget_Block_Interface) {
         return '';
     }
     return $widget->toHtml();
 }
コード例 #14
0
ファイル: Grid.php プロジェクト: r8-forks/CollectionNoDb
 /**
  * @return Convenient_AdminGrid_Model_Resource_Collection_Disk|Varien_Data_Collection
  *
  * @author Luke Rodgers <*****@*****.**>
  */
 public function getCollection()
 {
     if (is_null($this->_collection)) {
         $this->_collection = Mage::getResourceSingleton('convenient_admingrid/collection_disk');
     }
     return $this->_collection;
 }
コード例 #15
0
 public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
 {
     if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
         return $this->getNode($parentNodeCategory, $recursionLevel);
     }
     $root = Mage::registry('root');
     if (is_null($root)) {
         $storeId = (int) $this->getRequest()->getParam('store');
         if ($storeId) {
             $store = Mage::app()->getStore($storeId);
             $rootId = $store->getRootCategoryId();
         } else {
             $rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
         }
         $ids = $this->getSelectedCategoriesPathIds($rootId);
         $tree = Mage::getResourceSingleton('catalog/category_tree')->loadByIds($ids, false, false);
         if ($this->getCategory()) {
             $tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
         }
         $tree->addCollectionData($this->getCategoryCollection());
         $root = $tree->getNodeById($rootId);
         if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
             $root->setIsVisible(true);
             if ($this->isReadonly()) {
                 $root->setDisabled(true);
             }
         } elseif ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
             $root->setName(Mage::helper('catalog')->__('Root'));
         }
         Mage::register('root', $root);
     }
     return $root;
 }
コード例 #16
0
 /**
  * Return queue collection with loaded neversent queues
  *
  * @return Mage_Newsletter_Model_Mysql4_Queue_Collection
  */
 public function getQueueCollection()
 {
     if (is_null($this->_queueCollection)) {
         $this->_queueCollection = Mage::getResourceSingleton('newsletter/queue_collection')->addTemplateInfo()->addOnlyUnsentFilter()->load();
     }
     return $this->_queueCollection;
 }
コード例 #17
0
ファイル: Vote.php プロジェクト: arslbbt/mangentovies
 protected function _getResource()
 {
     if (!$this->_resource) {
         $this->_resource = Mage::getResourceSingleton('poll/poll_answer_vote');
     }
     return $this->_resource;
 }
コード例 #18
0
ファイル: Aggregate.php プロジェクト: smitmanglam/staging
 /**
  * @param Mana_Db_Model_Formula_Context $context
  * @param Mana_Db_Model_Formula_Entity $entity
  */
 public function select($context, $entity)
 {
     switch ($context->getMode()) {
         default:
             $context->setMode($this->getName())->setEntityHelper($this);
             /* @var $dbHelper Mana_Db_Helper_Data */
             $dbHelper = Mage::helper('mana_db');
             /* @var $resource Mana_Db_Resource_Formula */
             $resource = Mage::getResourceSingleton('mana_db/formula');
             $context->incrementPrefix();
             $alias = explode('.', $entity->getAlias());
             $alias = array_pop($alias);
             $aggregateContext = $context->createChildContext()->setPrefix($context->getPrefix())->setEntity($entity->getEntity())->setProcessor($entity->getProcessor())->setAlias($alias);
             $select = $aggregateContext->getSelect()->from(array($aggregateContext->registerAlias($alias) => $resource->getTable($dbHelper->getScopedName($entity->getEntity()))), null);
             if ($entity->getJoin()) {
                 foreach ($entity->getJoin() as $alias => $join) {
                     $method = isset($join['type']) ? 'join' . ucfirst($join['type']) : 'joinInner';
                     $select->{$method}(array($aggregateContext->registerAlias($alias) => $resource->getTable($dbHelper->getScopedName($join['entity']))), $aggregateContext->resolveAliases($join['on']), null);
                 }
             }
             if ($entity->getOrder()) {
                 $select->order($aggregateContext->resolveAliases($entity->getOrder(), false));
             }
             if ($entity->getWhere()) {
                 $select->where($aggregateContext->resolveAliases($entity->getWhere()));
             }
             $context->setEntity($entity->getEntity())->setProcessor($entity->getProcessor())->setAlias($entity->getAlias())->setAggregateContext($aggregateContext);
             break;
     }
 }
コード例 #19
0
ファイル: Main.php プロジェクト: ottonet/Magento-Faq
 /**
  * Preparation of current form
  *
  * @return Flagbit_Faq_Block_Admin_Edit_Tab_Main Self
  */
 protected function _prepareForm()
 {
     $model = Mage::registry('faq');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('faq_');
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('flagbit_faq')->__('General information'), 'class' => 'fieldset-wide'));
     if ($model->getFaqId()) {
         $fieldset->addField('faq_id', 'hidden', array('name' => 'faq_id'));
     }
     $fieldset->addField('question', 'text', array('name' => 'question', 'label' => Mage::helper('flagbit_faq')->__('FAQ item question'), 'title' => Mage::helper('flagbit_faq')->__('FAQ item question'), 'required' => true));
     /**
      * Check is single store mode
      */
     if (!Mage::app()->isSingleStoreMode()) {
         $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('cms')->__('Store view'), 'title' => Mage::helper('cms')->__('Store view'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId()));
         $model->setStoreId(Mage::app()->getStore(true)->getId());
     }
     $fieldset->addField('is_active', 'select', array('label' => Mage::helper('cms')->__('Status'), 'title' => Mage::helper('flagbit_faq')->__('Item status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('cms')->__('Enabled'), '0' => Mage::helper('cms')->__('Disabled'))));
     $fieldset->addField('category_id', 'multiselect', array('label' => Mage::helper('flagbit_faq')->__('Category'), 'title' => Mage::helper('flagbit_faq')->__('Category'), 'name' => 'categories[]', 'required' => false, 'values' => Mage::getResourceSingleton('flagbit_faq/category_collection')->toOptionArray()));
     $fieldset->addField('answer', 'editor', array('name' => 'answer', 'label' => Mage::helper('flagbit_faq')->__('Content'), 'title' => Mage::helper('flagbit_faq')->__('Content'), 'style' => 'height:36em;', 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(), 'required' => true));
     $fieldset->addField('answer_html', 'select', array('label' => Mage::helper('flagbit_faq')->__('HTML answer'), 'title' => Mage::helper('flagbit_faq')->__('HTML answer'), 'name' => 'answer_html', 'required' => true, 'options' => array('1' => Mage::helper('cms')->__('Enabled'), '0' => Mage::helper('cms')->__('Disabled'))));
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
コード例 #20
0
ファイル: Order.php プロジェクト: shashankkanungo/magento
 protected function _initCollection()
 {
     if ($vendor = Mage::helper('smvendors')->getVendorLogin()) {
         $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
         $this->_collection = Mage::getResourceSingleton('smvendors/reports_order_collection')->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
         if ($this->getParam('store')) {
             $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
         } else {
             if ($this->getParam('website')) {
                 $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
                 $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
             } else {
                 if ($this->getParam('group')) {
                     $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
                     $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
                 } elseif (!$this->_collection->isLive()) {
                     $this->_collection->addFieldToFilter('store_id', array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId()));
                 }
             }
         }
         $this->_collection->load();
     } else {
         parent::_initCollection();
     }
 }
コード例 #21
0
 /**
  * Process saving new encryption key
  *
  */
 public function saveAction()
 {
     try {
         $key = null;
         if (!$this->_checkIsLocalXmlWriteable()) {
             throw new Exception('');
         }
         if (0 == $this->getRequest()->getPost('generate_random')) {
             $key = $this->getRequest()->getPost('crypt_key');
             if (empty($key)) {
                 throw new Exception(Mage::helper('enterprise_pci')->__('Please enter an encryption key.'));
             }
             Mage::helper('core')->validateKey($key);
         }
         $newKey = Mage::getResourceSingleton('enterprise_pci/key_change')->changeEncryptionKey($key);
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('enterprise_pci')->__('Encryption key has been changed.'));
         if (!$key) {
             Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('enterprise_pci')->__('Your new encryption key: <span style="font-family:monospace;">%s</span>. Please make a note of it and make sure you keep it in a safe place.', $newKey));
         }
         Mage::app()->cleanCache();
     } catch (Exception $e) {
         if ($message = $e->getMessage()) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
         }
         Mage::getSingleton('adminhtml/session')->setFormData(array('crypt_key' => $key));
     }
     $this->_redirect('*/*/');
 }
コード例 #22
0
ファイル: Unsubscribe.php プロジェクト: jsiefer/emarketing
 /**
  * 
  * (non-PHPdoc)
  * @see Mzax_Bounce_Detector_Abstract::inspect()
  */
 public function inspect(Mzax_Bounce_Message $message)
 {
     $subject = trim($message->getSubject());
     if (preg_match('/^Unsubscribe ([^\\s]+) \\(([0-9A-Z]+)\\)$/i', $subject, $matches)) {
         $email = $matches[1];
         $hash = $matches[2];
         /* @var $recipient Mzax_Emarketing_Model_Recipient */
         $recipient = Mage::getModel('mzax_emarketing/recipient')->loadByBeacon($hash);
         if ($recipient->getId()) {
             $recipient->prepare();
             if (strtolower($recipient->getAddress()) == strtolower($email)) {
                 $message->info('recipient_id', $recipient->getId(), 200);
                 $message->info('campaign_id', $recipient->getCampaignId(), 200);
                 $message->info('recipient', $email, 200);
                 $message->info(Mzax_Bounce::TYPE_UNSUBSCRIBE, true);
                 $message->info('type', Mzax_Bounce::TYPE_UNSUBSCRIBE);
                 $storeId = Mage::getResourceSingleton('mzax_emarketing/recipient')->getStoreId($recipient->getId());
                 if ($storeId) {
                     $message->info('store_id', $storeId, 100);
                 }
                 return true;
                 // stop
             }
         }
     }
 }
コード例 #23
0
 /**
  * Atributos ativos dos clientes
  * (formato vetor: key => value)
  * 
  * @return array
  */
 public function toArray()
 {
     // atributos de clientes
     $attributes = array();
     $collection = Mage::getModel('customer/attribute')->getCollection();
     foreach ($collection as $attr) {
         // somente atributos visiveis
         if (!$attr->getIsVisible()) {
             continue;
         }
         $attributes[] = array("customer/" . $attr->getData('attribute_code') => "[" . Mage::helper('Query_NovaPontoCom')->__("Customer") . "] " . Mage::helper('Query_NovaPontoCom')->__($attr->getData('frontend_label')));
     }
     // atributos de enderecos de clientes
     $resource = Mage::getResourceSingleton('customer/address');
     $attrArray = Mage::getSingleton('eav/config')->getEntityAttributeCodes('customer_address', null);
     foreach ($attrArray as $attrCode) {
         $attributes[] = array("address/" . $attrCode => "[" . Mage::helper('Query_NovaPontoCom')->__("Address") . "] " . Mage::helper('Query_NovaPontoCom')->__($resource->getAttribute($attrCode)->getStoreLabel()));
     }
     // atributos rua
     $attributes[] = array('address/street_1' => "[" . Mage::helper('Query_NovaPontoCom')->__("Address") . "] " . Mage::helper('Query_NovaPontoCom')->__('Street 1'));
     $attributes[] = array('address/street_2' => "[" . Mage::helper('Query_NovaPontoCom')->__("Address") . "] " . Mage::helper('Query_NovaPontoCom')->__('Street 2'));
     $attributes[] = array('address/street_3' => "[" . Mage::helper('Query_NovaPontoCom')->__("Address") . "] " . Mage::helper('Query_NovaPontoCom')->__('Street 3'));
     $attributes[] = array('address/street_4' => "[" . Mage::helper('Query_NovaPontoCom')->__("Address") . "] " . Mage::helper('Query_NovaPontoCom')->__('Street 4'));
     return $attributes;
 }
コード例 #24
0
ファイル: Collection.php プロジェクト: nemphys/magento2
 /**
  * Retrieve CatalogInventory Stock Item Resource instance
  *
  * @return Mage_CatalogInventory_Model_Resource_Stock_Item
  */
 protected function _getInventoryItemResource()
 {
     if ($this->_inventoryItemResource === null) {
         $this->_inventoryItemResource = Mage::getResourceSingleton('Mage_CatalogInventory_Model_Resource_Stock_Item');
     }
     return $this->_inventoryItemResource;
 }
コード例 #25
0
ファイル: Sidebar.php プロジェクト: codercv/urbansurprisedev
 /**
  * Get array of last added items
  *
  * @return array
  */
 public function getRecentItems($count = null)
 {
     if ($count === null) {
         $count = $this->getItemCount();
     }
     $items = array();
     if (!$this->getSummaryCount()) {
         return $items;
     }
     $i = 0;
     $allItems = array_reverse($this->getItems());
     foreach ($allItems as $item) {
         /* @var $item Mage_Sales_Model_Quote_Item */
         if (!$item->getProduct()->isVisibleInSiteVisibility()) {
             $productId = $item->getProduct()->getId();
             $products = Mage::getResourceSingleton('catalog/url')->getRewriteByProductStore(array($productId => $item->getStoreId()));
             if (!isset($products[$productId])) {
                 continue;
             }
             $urlDataObject = new Varien_Object($products[$productId]);
             $item->getProduct()->setUrlDataObject($urlDataObject);
         }
         $items[] = $item;
         if (++$i == $count) {
             break;
         }
     }
     return $items;
 }
コード例 #26
0
ファイル: Stats.php プロジェクト: xiaoguizhidao/devfashion
 protected function _initCollection()
 {
     $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
     $this->_collection = Mage::getResourceSingleton('rewardpoints/stats_collection')->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
     if (Mage::getStoreConfig('rewardpoints/default/store_scope')) {
         if ($this->getParam('store')) {
             //$this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
             $this->_collection->addFieldToFilter('find_in_set(?, store_id)', $this->getParam('store'));
         } else {
             if ($this->getParam('website')) {
                 $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
                 //$this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
                 foreach ($storeIds as $storeId) {
                     $this->_collection->addFieldToFilter('find_in_set(?, store_id)', $storeId);
                 }
             } else {
                 if ($this->getParam('group')) {
                     $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
                     //$this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
                     foreach ($storeIds as $storeId) {
                         $this->_collection->addFieldToFilter('find_in_set(?, store_id)', $storeId);
                     }
                 } else {
                     /*$this->_collection->addFieldToFilter('store_id',
                           array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
                       );*/
                     $this->_collection->addFieldToFilter('find_in_set(?, store_id)', Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId());
                 }
             }
         }
     }
     $this->_collection->load();
 }
コード例 #27
0
 /**
  * Retrieve CatalogInventory Stock Item Resource instance
  *
  * @return Mage_CatalogInventory_Model_Resource_Stock_Item
  */
 protected function _getInventoryItemResource()
 {
     if ($this->_inventoryItemResource === null) {
         $this->_inventoryItemResource = Mage::getResourceSingleton('cataloginventory/stock_item');
     }
     return $this->_inventoryItemResource;
 }
コード例 #28
0
 /**
  * Prepare url using passed id path and return it
  * or return false if path was not found in url rewrites.
  *
  * @return string|false
  */
 public function getHref()
 {
     if (!$this->_href) {
         if ($this->hasStoreId()) {
             $store = Mage::app()->getStore($this->getStoreId());
         } else {
             $store = Mage::app()->getStore();
         }
         /* @var $store Mage_Core_Model_Store */
         $href = "";
         if ($this->getData('id_path')) {
             /* @var $urlRewriteResource Mage_Core_Model_Mysql4_Url_Rewrite */
             $urlRewriteResource = Mage::getResourceSingleton('core/url_rewrite');
             $href = $urlRewriteResource->getRequestPathByIdPath($this->getData('id_path'), $store);
             if (!$href) {
                 return false;
             }
         }
         $this->_href = $store->getUrl('', array('_direct' => $href));
     }
     if (strpos($this->_href, "___store") === false) {
         $symbol = strpos($this->_href, "?") === false ? "?" : "&";
         $this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
     }
     return $this->_href;
 }
コード例 #29
0
 public function addItemCountExpr()
 {
     $orderTable = $this->getEntity()->getEntityTable();
     $orderItemEntityTypeId = Mage::getResourceSingleton('sales/order_item')->getTypeId();
     $this->getSelect()->join(array('items' => $orderTable), 'items.parent_id=e.entity_id and items.entity_type_id=' . $orderItemEntityTypeId, array('items_count' => new Zend_Db_Expr('COUNT(items.entity_id)')))->group('e.entity_id');
     return $this;
 }
コード例 #30
0
ファイル: Collection.php プロジェクト: CE-Webmaster/CE-Hub
 protected function _initSelect()
 {
     parent::_initSelect();
     $modelCat = Mage::getResourceSingleton('downloads/categories');
     $this->getSelect()->joinLeft(array('relation' => $this->getTable('downloads/relation')), 'main_table.file_id = relation.file_id', array('products_count' => 'COUNT(relation.product_id)'))->joinLeft(array('cat' => $modelCat->getMainTable()), 'main_table.category_id = cat.category_id', array('title'))->group('main_table.file_id');
     return $this;
 }