/**
  * Prepare select for condition
  *
  * @param int $storeId
  * @param Mage_Rule_Model_Condition_Abstract $condition
  * @return Varien_Db_Select
  */
 public function getProductFlatSelect($storeId, $condition)
 {
     $select = $this->_getReadAdapter()->select();
     $select->from(array('p' => $this->getTable('catalog/product')), array(new Zend_Db_Expr('DISTINCT p.entity_id')))->joinInner(array('cpf' => $this->getTable('catalog/product_flat') . '_' . $storeId), 'cpf.entity_id = p.entity_id', array())->joinLeft(array('ccp' => $this->getTable('catalog/category_product')), 'ccp.product_id = p.entity_id', array());
     $where = $condition->prepareConditionSql();
     if (!empty($where)) {
         $select->where($where);
     }
     return $select;
 }