/** * Test for method filterEntityCollection() * * @magentoDataFixture Mage/ImportExport/_files/customers.php */ public function testFilterEntityCollection() { $createdAtDate = '2038-01-01'; /** * Change created_at date of first customer for future filter test. */ $customers = Mage::registry('_fixture/Mage_ImportExport_Customer_Collection'); $customers[0]->setCreatedAt($createdAtDate); $customers[0]->save(); /** * Change type of created_at attribute. In this case we have possibility to test date rage filter */ $attributeCollection = Mage::getResourceModel('Mage_Customer_Model_Resource_Attribute_Collection'); $attributeCollection->addFieldToFilter('attribute_code', 'created_at'); /** @var $createdAtAttribute Mage_Customer_Model_Attribute */ $createdAtAttribute = $attributeCollection->getFirstItem(); $createdAtAttribute->setBackendType('datetime'); $createdAtAttribute->save(); /** * Prepare filter.asd */ $parameters = array(Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP => array('email' => 'example.com', 'created_at' => array($createdAtDate, ''), 'store_id' => Mage::app()->getStore()->getId())); $this->_model->setParameters($parameters); /** @var $customers Mage_Customer_Model_Resource_Customer_Collection */ $collection = $this->_model->filterEntityCollection(Mage::getResourceModel('Mage_Customer_Model_Resource_Customer_Collection')); $collection->load(); $this->assertCount(1, $collection); $this->assertEquals($customers[0]->getId(), $collection->getFirstItem()->getId()); }
/** * Initialize existent customers data * * @return Mage_ImportExport_Model_Export_Entity_Eav_Customer_Address */ protected function _initCustomers() { if (empty($this->_customers)) { // add customer default addresses column name to customer attribute mapping array $this->_customerCollection->addAttributeToSelect(self::$_defaultAddressAttributeMapping); // filter customer collection $this->_customerCollection = $this->_customerEntity->filterEntityCollection($this->_customerCollection); $customers = array(); $addCustomer = function (Mage_Customer_Model_Customer $customer) use(&$customers) { $customers[$customer->getId()] = $customer->getData(); }; $this->_byPagesIterator->iterate($this->_customerCollection, $this->_pageSize, array($addCustomer)); $this->_customers = $customers; } return $this; }