Implement additional export type for Google catalog
This commit is contained in:
@@ -34,9 +34,25 @@ use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentValueException;
|
||||
|
||||
class ResellerController extends ActionController
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $imageDimensions = [
|
||||
'facebook' => [
|
||||
'width' => '1080',
|
||||
'maxHeight' => '1080',
|
||||
'cropVariant' => 'facebook',
|
||||
],
|
||||
'google' => [
|
||||
'width' => '1200',
|
||||
'maxHeight' => '1200',
|
||||
'cropVariant' => 'google',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ResellerDataService
|
||||
@@ -99,7 +115,7 @@ class ResellerController extends ActionController
|
||||
|
||||
$serializer = new Serializer($normalizers, $encoders);
|
||||
|
||||
$filename = 'export_' . $reseller->getCode() . '_' . date('Y-m-d') . '.xml';
|
||||
$filename = sprintf('export_%s_%s.xml', $reseller->getCode(), date('Y-m-d'));
|
||||
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Content-Description: File Transfer');
|
||||
@@ -115,13 +131,19 @@ class ResellerController extends ActionController
|
||||
|
||||
/**
|
||||
* @param Reseller $reseller
|
||||
* @return bool
|
||||
* @param string $type
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
* @throws InvalidArgumentValueException
|
||||
*/
|
||||
public function csvAction(Reseller $reseller)
|
||||
public function csvAction(Reseller $reseller, $type = 'facebook')
|
||||
{
|
||||
$data = $this->resellerDataService->preprocessAll($reseller, [ 'width' => '1080', 'maxHeight' => '1080', 'cropVariant' => 'facebook' ]);
|
||||
if (!array_key_exists($type, static::$imageDimensions)) {
|
||||
throw new InvalidArgumentValueException();
|
||||
}
|
||||
|
||||
$filename = 'export_' . $reseller->getCode() . '_' . date('Y-m-d') . '.csv';
|
||||
$data = $this->resellerDataService->preprocessAll($reseller, static::$imageDimensions[$type]);
|
||||
|
||||
$filename = sprintf('export_%s_%s.csv', $reseller->getCode(), date('Y-m-d'));
|
||||
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Content-Description: File Transfer');
|
||||
@@ -144,15 +166,12 @@ class ResellerController extends ActionController
|
||||
'brand',
|
||||
]);
|
||||
|
||||
foreach ($data['product'] as $product)
|
||||
{
|
||||
foreach ($data['product'] as $product) {
|
||||
$minPrice = 0;
|
||||
$available = 0;
|
||||
|
||||
foreach ($product['hotels']['hotel'] as $hotel)
|
||||
{
|
||||
foreach ($hotel['dates']['date'] as $date)
|
||||
{
|
||||
foreach ($product['hotels']['hotel'] as $hotel) {
|
||||
foreach ($hotel['dates']['date'] as $date) {
|
||||
if ($minPrice === 0 || $date['minprice'] < $minPrice) {
|
||||
$minPrice = $date['minprice'];
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = [
|
||||
'GETvar' => 'tx_epproducts_reseller[action]',
|
||||
],
|
||||
[
|
||||
'GETvar' => 'tx_epproducts_reseller[product]',
|
||||
'GETvar' => 'tx_epproducts_reseller[type]',
|
||||
],
|
||||
],
|
||||
41 => 'searchresult',
|
||||
|
||||
Reference in New Issue
Block a user