質問

注文コレクションのフィルタを適用しています。私は状況で立ち往生しています、私は "Customer Address"にカスタム属性を追加しました。つまり、テーブル "Customer_Address_entity_varchar"にあります。迷惑なように、私はそれが正しいことではないことを知っています。

$orderCollection = Mage::getModel('sales/order')->getCollection();
            //Filter for excluding Stores
        if (!empty($excludeStoresIds)) {
            $excludeStoresIds = explode(',', $excludeStoresIds);
            $excludeStoresIds = array_map('trim', $excludeStoresIds); //Remove white spaces
            $orderCollection->getSelect()->joinLeft(array('sfoa' => 'sales_flat_order_address'), 'main_table.entity_id = sfoa.parent_id', "");
            $orderCollection->addFieldToFilter('sfoa.address_type', array('eq' => 'shipping'));
            $orderCollection->getSelect()->joinLeft(array('sfoa' => 'sales_flat_order_address','caev' => 'customer_address_entity_varchar'), 'sfoa.customer_address_id = caev.entity_id', "");
            $orderCollection->addFieldToFilter('caev.value', array('nin' => $excludeStoresIds));
        }
.

ここ $ excludestoresids は配列

です。

役に立ちましたか?

解決

ありがとう@魔法使い

$orderCollection->getSelect()->joinLeft(array('sfoa' => 'sales_flat_order_address'), 'main_table.entity_id = sfoa.parent_id', "");
            $orderCollection->addFieldToFilter('sfoa.address_type', array('eq' => 'shipping'));
            $orderCollection->getSelect()->joinLeft(array('caev' => 'customer_address_entity_varchar'), 'caev.entity_id = sfoa.customer_address_id', "");
            $orderCollection->addFieldToFilter('caev.value', array('nin' => $excludeStoresIds));
.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top