This commit is contained in:
@@ -42,15 +42,19 @@ class Jtl
|
||||
* Holt alle Produkte und deren Lagerbestände
|
||||
* @return array
|
||||
*/
|
||||
public function getProducts(): array
|
||||
public function getProducts(int $warehouseId): array
|
||||
{
|
||||
|
||||
$r = $this->productRepository->findAll();
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach ($r as $product) {
|
||||
$stock = $this->stockRepository->findBy(['product_id' => $product->getId()]);
|
||||
|
||||
if ($warehouseId != 0) {
|
||||
$stock = $this->stockRepository->findBy(['product_id' => $product->getId(), 'warehouse_id' => $warehouseId]);
|
||||
} else {
|
||||
$stock = $this->stockRepository->findBy(['product_id' => $product->getId()]);
|
||||
}
|
||||
|
||||
if ($stock) {
|
||||
foreach ($stock as $s) {
|
||||
@@ -83,17 +87,17 @@ class Jtl
|
||||
* @param $data
|
||||
* @return void
|
||||
*/
|
||||
public function createExportFile($data): void
|
||||
public function createExportFile($data, $warehouse): void
|
||||
{
|
||||
try {
|
||||
$writer = Writer::createFromPath(getcwd() . '/www/jtl/cds-export.csv', 'w+');
|
||||
$writer = Writer::createFromPath(getcwd() . '/www/jtl/' . $warehouse . '.csv', 'w+');
|
||||
$bytes = $writer->insertAll(new ArrayIterator($data));
|
||||
|
||||
if ($bytes) {
|
||||
$this->logger->info('Exported ' . $bytes . ' bytes');
|
||||
|
||||
$FTP = new Ftp();
|
||||
$FTP->uploadFile(getcwd() . '/www/jtl/cds-export.csv');
|
||||
$FTP->uploadFile(getcwd() . '/www/jtl/' . $warehouse . '.csv');
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user