Improvements in queryEcommerceItems function which make it works with segments query builder and add support for "log_conversion_item" table in segmenetation to join this table with log_visit.
Thanks for the PR!
The tests are failing: https://travis-ci.org/piwik/piwik/jobs/12363492
eg.
"Table 'log_link_visit_action', can't be joined for segmentation
<a href='/0'>#0</a> /home/travis/build/piwik/piwik/core/Segment.php(175): Piwik\Segment->generateJoins(Array)
<a href='/1'>#1</a> /home/travis/build/piwik/piwik/core/DataAccess/LogAggregator.php(87): Piwik\Segment->getSelectQuery('name as label, ...', Array, ' server_time >=...', Array, false, 'ecommerceType, ...')
<a href='/2'>#2</a> /home/travis/build/piwik/piwik/core/DataAccess/LogAggregator.php(354): Piwik\DataAccess\LogAggregator->generateQuery('name as label, ...', Array, ' server_time >=...', 'ecommerceType, ...', false)
<a href='/3'>#3</a> /home/travis/build/piwik/piwik/plugins/Goals/Archiver.php(236): Piwik\DataAccess\LogAggregator->queryEcommerceItems('idaction_sku')
<a href='/4'>#4</a> /home/travis/build/piwik/piwik/plugins/Goals/Archiver.php(90): Piwik\Plugins\Goals\Archiver->archiveEcommerceItems()
<a href='/5'>#5</a> /home/travis/build/piwik/piwik/plugins/Goals/Goals.php(505): Piwik\Plugins\Goals\Archiver->archiveDay()
<a href='/6'>#6</a> [internal function]: Piwik\Plugins\Goals\Goals->archiveDay(Object(Piwik\ArchiveProcessor\Day))
<a href='/7'>#7</a> /home/travis/build/piwik/piwik/core/EventDispatcher.php(98): call_user_func_array(Array, Array)
<a href='/8'>#8</a> /home/travis/build/piwik/piwik/core/Piwik.php(658): Piwik\EventDispatcher->postEvent('ArchiveProcesso...', Array, false, NULL)
<a href='/9'>#9</a> /home/travis/build/piwik/piwik/core/ArchiveProcessor/Day.php(124): Piwik\Piwik::postEvent('ArchiveProcesso...', Array)
<a href='/10'>#10</a> /home/travis/build/piwik/piwik/core/ArchiveProcessor.php(295): Piwik\ArchiveProcessor\Day->compute()
<a href='/11'>#11</a> /home/travis/build/piwik/piwik/core/ArchiveProcessor.php(198): Piwik\ArchiveProcessor->computeNewArchive('VisitsSummary', false)
<a href='/12'>#12</a> /home/travis/build/piwik/piwik/core/Archive.php(487): Piwik\ArchiveProcessor->preProcessArchive('VisitsSummary')
<a href='/13'>#13</a> /home/travis/build/piwik/piwik/core/Archive.php(403): Piwik\Archive->cacheArchiveIdsAfterLaunching(Array, Array)
Please fix build before I can merge PR.
Along with the PR here are suggestions for new tests:
Then these tests will generate new XML in processed/* directory. You can check these XML are correct and return only those products that were done by visitors matching the segment.
If the XML are valid copy them to the expected/* folder. Then run the tests again, they should pass (or repeat until they pass).
Btw the best way to run all tests is in the root of piwik run:
./console tests:run
if you want to run specific test:
cd tests/PHPUnit/ && phpunit Integration/EcommerceOrderWithItemsTest.php
Note; running takes takes long time. Hope it helps to make a Pull Request including tests
If travis is green then the PR should be safe to merge (and we know functionnality will not break in the future, which is an amazing feeling!)
Looks that tests passed. I've add to EcommerceOrderWithItemsTest acceptance tests with segment parameter and it works. :)