Ticket 375 : Fix duplicate Export CRM for newsletter
This commit is contained in:
parent
ccfb6acefb
commit
44ca6f86d6
1 changed files with 7 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ use App\Models\Customer;
|
|||
use App\Models\CustomerInfo;
|
||||
use App\Models\CustomerLogin;
|
||||
use App\Models\SingleOptin;
|
||||
use Exception;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
|
@ -179,11 +180,11 @@ class CustomerController extends Controller
|
|||
$continue = true;
|
||||
// continue
|
||||
case CustomerExportType::customer():
|
||||
$i = 0;
|
||||
$page = 1;
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $req */
|
||||
$req = CustomerInfo::where('brand_id', $request->brand);
|
||||
$total = $req->count();
|
||||
$pages = $total / $pagination;
|
||||
$pages = \ceil($total / $pagination);
|
||||
do {
|
||||
/** @var \Illuminate\Pagination\LengthAwarePaginator $items */
|
||||
$items = $req->with('customer', function ($q) {
|
||||
|
|
@ -192,7 +193,7 @@ class CustomerController extends Controller
|
|||
$pagination,
|
||||
['lastname', 'firstname', 'hashcode', 'customer_id'],
|
||||
'page',
|
||||
$i
|
||||
$page
|
||||
);
|
||||
$items->map(function (CustomerInfo $customerInfo) use ($w) {
|
||||
$w->insertOne([
|
||||
|
|
@ -202,7 +203,7 @@ class CustomerController extends Controller
|
|||
'hashcode' => $customerInfo->hashcode
|
||||
]);
|
||||
});
|
||||
} while ($i++ <= $pages);
|
||||
} while ($page++ <= $pages);
|
||||
if (!isset($continue)) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -218,6 +219,8 @@ class CustomerController extends Controller
|
|||
]);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf('Unhandled CustomerExportType %s', $exportType->label));
|
||||
}
|
||||
|
||||
//we create a callable to output the CSV in chunk
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue