سؤال

أقوم بتطبيق عامل التصفية على جمع الطلب.أنا عالق في موقف ما، لقد أضفت سمة مخصصة إلى "عنوان العميل".الموجود في الجدول "customer_address_entity_varchar"، والآن لا بد لي من الانضمام إلى الجداول الثلاثة التالية، (1)sales_flat_order (2)sales_flat_order_address (3) 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