Example #1
0
 protected function _construct()
 {
     parent::_construct();
     $collection = Mage::getResourceModel('affiliateplusprogram/program_collection');
     //$collection->setStoreId(Mage::app()->getStore()->getId());
     $collection->getSelect()->join(array('account' => $collection->getTable('affiliateplusprogram/account')), 'main_table.program_id = account.program_id', array('joined_at' => 'joined'))->where('account.account_id = ?', $this->_getAccountHelper()->getAccount()->getId());
     // join program name and filter status
     $collection->getSelect()->joinLeft(array('n' => $collection->getTable('affiliateplusprogram/value')), "main_table.program_id = n.program_id AND n.attribute_code = 'name' AND n.store_id = " . Mage::app()->getStore()->getId(), array('program_name' => 'IF (n.value IS NULL, main_table.name, n.value)'))->joinLeft(array('s' => $collection->getTable('affiliateplusprogram/value')), "main_table.program_id = s.program_id AND s.attribute_code = 'status' AND s.store_id = " . Mage::app()->getStore()->getId(), array())->where('IF(s.value IS NULL, main_table.status, s.value) = 1');
     $this->setCollection($collection);
 }
Example #2
0
 protected function _construct()
 {
     parent::_construct();
     $collection = Mage::getResourceModel('affiliateplusprogram/program_collection')->setStoreId(Mage::app()->getStore()->getId())->addFieldToFilter('main_table.program_id', array('nin' => $this->_getHelper()->getJoinedProgramIds()));
     $group = Mage::getSingleton('customer/session')->getCustomer()->getGroupId();
     $collection->getSelect()->where("scope = 0 OR (scope = 1 AND FIND_IN_SET({$group},customer_groups) )");
     // join program name and filter status
     $collection->getSelect()->joinLeft(array('n' => $collection->getTable('affiliateplusprogram/value')), "main_table.program_id = n.program_id AND n.attribute_code = 'name' AND n.store_id = " . Mage::app()->getStore()->getId(), array('program_name' => 'IF (n.value IS NULL, main_table.name, n.value)'))->joinLeft(array('s' => $collection->getTable('affiliateplusprogram/value')), "main_table.program_id = s.program_id AND s.attribute_code = 'status' AND s.store_id = " . Mage::app()->getStore()->getId(), array())->where('IF(s.value IS NULL, main_table.status, s.value) = 1');
     $this->setCollection($collection);
 }