private function generateBatches($csvImages, $itemForBatch) { $source = HelperFileFormatting::csvToArray($csvImages); $batches = array_chunk($source, $itemForBatch); $columDefinition = array('idProduct', 'pathImg'); $batches = HelperFileFormatting::unshiftColumDefinition($batches, $columDefinition); foreach ($batches as $key => $batch) { $batchName = BATCHES_PATH . 'batch' . $key . '.csv'; $zipName = BATCHES_PATH . 'batch' . $key . '.zip'; HelperFileFormatting::createCsv($batch, $batchName, ','); HelperFileFormatting::createZip($zipName, $this->getImagesFromBatch($batch), IMAGES_PATH); } }
private function getSimpleProductInfo($csvsPaths) { $allProducts = []; $files = glob($csvsPaths . '*.csv'); foreach ($files as $file) { $productsBache = HelperFileFormatting::csvToArray($file, '|'); foreach ($productsBache as $product) { $id = $product[0]; $name = $product[1]; if ($product[0] != 'id') { $rowCsv = array($id, $name); $allProducts[] = $rowCsv; } } } return $allProducts; }