Magento - getEntityTable()指向哪个表?

时间:2012-08-09 11:31:23

标签: php magento magento-1.5 magento-1.6

class Mage_Sales_Model_Entity_Order_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{

    protected function _construct()
    {
        $this->_init('sales/order');
    }

    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;
    }
}

1 个答案:

答案 0 :(得分:0)

/code/core/Mage/Sales/etc/config.xml 中定义:

<order><table>sales_flat_order</table></order>

'sales/order'模型表格为: sales_flat_order