public function testCfg()
 {
     // System / Configuration
     $this->assertTrue(is_array(Praxigento_Quickorder_Config::cfgCustomerGroupsAllowed()));
     $this->assertTrue(is_array(Praxigento_Quickorder_Config::cfgSearchAttributes()));
     $this->assertTrue(is_bool(Praxigento_Quickorder_Config::cfgOutOfStockEnabled()));
     $this->assertTrue(is_bool(Praxigento_Quickorder_Config::cfgInvisibleIncluded()));
     $this->assertTrue(is_bool(Praxigento_Quickorder_Config::cfgComplexProdsIncluded()));
     $this->assertTrue(is_string(Praxigento_Quickorder_Config::cfgSortAttr()));
     $this->assertTrue(is_string(Praxigento_Quickorder_Config::cfgSortOrder()));
 }
 /**
  * Collect products according to configuration parameters and query from the QOF.
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 public function getProductCollection()
 {
     /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
     $collection = Mage::getModel('catalog/product')->getResourceCollection()->addAttributeToSelect('*')->addMinimalPrice()->addFinalPrice()->addTaxPercents();
     /** Setup filter by product visibility */
     if (!Praxigento_Quickorder_Config::cfgInvisibleIncluded()) {
         /** @var $prodVisible Mage_Catalog_Model_Product_Visibility */
         $prodVisible = Mage::getSingleton('catalog/product_visibility');
         $collection->setVisibility($prodVisible->getVisibleInSiteIds());
     }
     /** Setup filter by product type */
     /** complex prods need a Ajax panel to configire options pn-the-fly */
     //        if (!Praxigento_Quickorder_Config::cfgComplexProdsIncluded()) {
     /** exclude configurable, grouped, bundled products and any custom types */
     $collection->addAttributeToFilter('type_id', array('in', array('simple', 'virtual', 'downloadable')));
     //        }
     /** filter products by customer's query */
     $conditions = array();
     foreach ($this->_filters as $filter) {
         $conditions[] = array('attribute' => $filter, 'like' => "%{$this->_query}%");
     }
     $collection->addAttributeToFilter($conditions);
     /** sort result set */
     $attr = Praxigento_Quickorder_Config::cfgSortAttr();
     $order = Praxigento_Quickorder_Config::cfgSortOrder();
     $collection->addAttributeToSort($attr, $order);
     /** remove out of stock items in case of Magento is configured to show items but QOF - to hide */
     if (Mage::helper('cataloginventory')->isShowOutOfStock() && !Praxigento_Quickorder_Config::cfgOutOfStockEnabled()) {
         /** @var $item Mage_Catalog_Model_Product */
         foreach ($collection as $key => $item) {
             $inventory = $item->getStockItem();
             if (!$inventory->getData('is_in_stock')) {
                 $collection->removeItemByKey($key);
             }
         }
     }
     return $collection;
 }