Working import stock

modifié:         core/lib/Thelia/Controller/Admin/ExportController.php
	modifié:         core/lib/Thelia/Controller/Admin/ImportController.php
	modifié:         core/lib/Thelia/Core/Event/ImportExport.php
	modifié:         core/lib/Thelia/Core/Event/TheliaEvents.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/AbstractFormatter.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/FormatterData.php
	modifié:         core/lib/Thelia/ImportExport/Import/Type/ProductStockImport.php
	modifié:         templates/backOffice/default/ajax/import-modal.html
	modifié:         templates/backOffice/default/import-page.html
This commit is contained in:
Benjamin Perche
2014-07-17 17:00:53 +02:00
parent 069d2a07d9
commit cb75c13716
10 changed files with 131 additions and 50 deletions

View File

@@ -11,10 +11,10 @@
/*************************************************************************************/
namespace Thelia\Core\Event;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\ImportExport\AbstractHandler;
use Thelia\ImportExport\Export\ExportHandler;
/**
@@ -24,7 +24,7 @@ use Thelia\ImportExport\Export\ExportHandler;
*/
class ImportExport extends ActionEvent
{
/** @var \Thelia\ImportExport\Export\ExportHandler */
/** @var \Thelia\ImportExport\AbstractHandler */
protected $handler;
/** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter */
@@ -36,10 +36,13 @@ class ImportExport extends ActionEvent
/** @var \Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder */
protected $archiveBuilder;
/** @var mixed */
protected $content;
public function __construct(
AbstractFormatter $formatter,
\Thelia\ImportExport\Export\ExportHandler $handler,
FormatterData $data,
AbstractFormatter $formatter = null,
AbstractHandler $handler = null,
FormatterData $data = null,
AbstractArchiveBuilder $archiveBuilder = null
) {
$this->archiveBuilder = $archiveBuilder;
@@ -123,4 +126,25 @@ class ImportExport extends ActionEvent
{
return $this->data;
}
/**
* @param $content
* @return $this
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* @return mixed
*/
public function getContent()
{
return $this->content;
}
}

View File

@@ -769,5 +769,9 @@ final class TheliaEvents
// -- Export ----------------------------------------------
const BEFORE_EXPORT = "Thelia.before.export";
const EXPORT_BEFORE_ENCODE = "Thelia.export.encode.before";
const EXPORT_AFTER_ENCODE = "Thelia.export.encode.after";
const IMPORT_BEFORE_DECODE = "Thelia.import.decode.before";
const IMPORT_AFTER_DECODE = "Thelia.import.decode.after";
}

View File

@@ -22,7 +22,7 @@ use Thelia\Log\Tlog;
*/
abstract class AbstractFormatter implements FormatInterface, FormatterInterface
{
const FILENAME = "export";
const FILENAME = "data";
/** @var \Thelia\Core\Translation\Translator */
protected $translator;

View File

@@ -83,7 +83,7 @@ class JsonFormatter extends AbstractFormatter
*/
public function decode($rawData)
{
return (new FormatterData($this->getAliases()))->setData(
return (new FormatterData())->setData(
json_decode($rawData, true)
);
}

View File

@@ -172,13 +172,9 @@ class FormatterData
* @param int $index
* @return array|bool
*/
public function popRow($index = 0)
public function popRow()
{
$row = $this->getRow($index);
if (false !== $row) {
unset($this->data[$index]);
}
$row = array_pop($this->data);
return $row;
}