Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

I managed to get this to work using Marius advice and using the answer from the post below:

Collection with FIND_IN_SET on multiselect attributes, but some has only one valueCollection with FIND_IN_SET on multiselect attributes, but some has only one value

My code now reads

    function getHomePageBanners() {
    
    $storeId = Mage::app()->getStore()->getStoreId();
    $customerId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    
    $collection = Mage::getModel("homepagebanner/homepagebanner")->getCollection()
            ->addFieldToFilter('status', array('eq' => 0))
            ->addFieldToFilter('store_view_id',
                array(
                    array('finset'=> array('0')),
                    array('finset'=> array($storeId)),
                )
            )
            ->addFieldToFilter('customer_group_id',array('finset'=>array($customerId)))
            ->setOrder('position', 'ASC')
            ->toArray();
    
    return $collection['items'];
}

I managed to get this to work using Marius advice and using the answer from the post below:

Collection with FIND_IN_SET on multiselect attributes, but some has only one value

My code now reads

    function getHomePageBanners() {
    
    $storeId = Mage::app()->getStore()->getStoreId();
    $customerId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    
    $collection = Mage::getModel("homepagebanner/homepagebanner")->getCollection()
            ->addFieldToFilter('status', array('eq' => 0))
            ->addFieldToFilter('store_view_id',
                array(
                    array('finset'=> array('0')),
                    array('finset'=> array($storeId)),
                )
            )
            ->addFieldToFilter('customer_group_id',array('finset'=>array($customerId)))
            ->setOrder('position', 'ASC')
            ->toArray();
    
    return $collection['items'];
}

I managed to get this to work using Marius advice and using the answer from the post below:

Collection with FIND_IN_SET on multiselect attributes, but some has only one value

My code now reads

    function getHomePageBanners() {
    
    $storeId = Mage::app()->getStore()->getStoreId();
    $customerId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    
    $collection = Mage::getModel("homepagebanner/homepagebanner")->getCollection()
            ->addFieldToFilter('status', array('eq' => 0))
            ->addFieldToFilter('store_view_id',
                array(
                    array('finset'=> array('0')),
                    array('finset'=> array($storeId)),
                )
            )
            ->addFieldToFilter('customer_group_id',array('finset'=>array($customerId)))
            ->setOrder('position', 'ASC')
            ->toArray();
    
    return $collection['items'];
}
Source Link
Ryan
  • 33
  • 1
  • 1
  • 6

I managed to get this to work using Marius advice and using the answer from the post below:

Collection with FIND_IN_SET on multiselect attributes, but some has only one value

My code now reads

    function getHomePageBanners() {
    
    $storeId = Mage::app()->getStore()->getStoreId();
    $customerId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    
    $collection = Mage::getModel("homepagebanner/homepagebanner")->getCollection()
            ->addFieldToFilter('status', array('eq' => 0))
            ->addFieldToFilter('store_view_id',
                array(
                    array('finset'=> array('0')),
                    array('finset'=> array($storeId)),
                )
            )
            ->addFieldToFilter('customer_group_id',array('finset'=>array($customerId)))
            ->setOrder('position', 'ASC')
            ->toArray();
    
    return $collection['items'];
}