wip: product filters

This commit is contained in:
2025-10-03 22:32:31 +03:00
parent a051ff545e
commit da1b71fc89
48 changed files with 721 additions and 235 deletions

View File

@@ -10,6 +10,10 @@ use InvalidArgumentException;
class Builder
{
public const JOIN_TYPE_LEFT = 'LEFT';
public const JOIN_TYPE_INNER = 'INNER';
public const JOIN_TYPE_RIGHT = 'RIGHT';
private $connection;
private $grammar;
@@ -46,7 +50,7 @@ class Builder
$this->columns = [];
$this->bindings['select'] = [];
if (!$columns) {
if (! $columns) {
throw new InvalidArgumentException('Select columns not provided');
}
@@ -231,7 +235,7 @@ class Builder
{
$direction = strtoupper($direction);
if (!in_array($direction, ['ASC', 'DESC'], true)) {
if (! in_array($direction, ['ASC', 'DESC'], true)) {
throw new InvalidArgumentException('Order direction must be "ASC" or "DESC".');
}
@@ -251,7 +255,7 @@ class Builder
public function toRawSql(): string
{
return $this->substituteBindingsIntoRawSql(
$this->toSql(),
str_replace("\n", ' ', $this->toSql()),
$this->getBindings()
);
}
@@ -280,8 +284,8 @@ class Builder
++$i;
} elseif ($char === "'") { // Starting / leaving string literal...
$query .= $char;
$isStringLiteral = !$isStringLiteral;
} elseif ($char === '?' && !$isStringLiteral) { // Substitutable binding...
$isStringLiteral = ! $isStringLiteral;
} elseif ($char === '?' && ! $isStringLiteral) { // Substitutable binding...
$query .= array_shift($bindings) ?? '?';
} else { // Normal character...
$query .= $char;
@@ -348,7 +352,7 @@ class Builder
public function addBinding($value, $type = 'where'): Builder
{
if (!array_key_exists($type, $this->bindings)) {
if (! array_key_exists($type, $this->bindings)) {
throw new InvalidArgumentException("Invalid binding type: {$type}.");
}
@@ -362,9 +366,15 @@ class Builder
Utils::dd($this->toSql(), $this->getBindings());
}
public function join(string $table, Closure $joinClosure, $type = 'inner'): Builder
/**
* @param Table|string $table
* @param Closure $joinClosure
* @param $type
* @return $this
*/
public function join($table, Closure $joinClosure, $type = self::JOIN_TYPE_INNER): Builder
{
$joinClause = new JoinClause($this, $type, $table);
$joinClause = new JoinClause($this, $type, (string) $table);
$joinClosure($joinClause);
@@ -374,9 +384,14 @@ class Builder
return $this;
}
public function leftJoin(string $table, Closure $joinClosure): Builder
/**
* @param Table|string $table
* @param Closure $joinClosure
* @return $this
*/
public function leftJoin($table, Closure $joinClosure): Builder
{
return $this->join($table, $joinClosure, 'left');
return $this->join($table, $joinClosure, self::JOIN_TYPE_LEFT);
}
public function getConnection(): ConnectionInterface

View File

@@ -0,0 +1,51 @@
<?php
namespace Openguru\OpenCartFramework\QueryBuilder;
use InvalidArgumentException;
use Stringable;
class Table implements Stringable
{
private $table;
private ?string $alias;
/**
* @param string|Builder $table
* @param string|null $alias
*/
public function __construct($table, ?string $alias = null)
{
$this->table = $table;
$this->alias = $alias;
if ($this->table instanceof Builder && ! $this->getAlias()) {
throw new InvalidArgumentException('Alias required for Sub Queries');
}
}
/**
* @return Builder|string
*/
public function getTable()
{
return $this->table;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function __toString(): string
{
$table = $this->getTable();
$alias = $this->getAlias();
if ($table instanceof Builder) {
$table = '(' . $table->toRawSql() . ')';
}
return $table . ($alias ? ' AS ' . $alias : '');
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\FacetSearch\Filters;
namespace App\Filters;
use InvalidArgumentException;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\FacetSearch\Filters;
namespace App\Filters;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\FacetSearch\Filters;
namespace App\Filters;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\FacetSearch\Filters;
namespace App\Filters;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\FacetSearch\Filters;
namespace App\Filters;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\FacetSearch\Filters;
namespace App\Filters;
use InvalidArgumentException;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
@@ -10,6 +10,7 @@ use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
use Openguru\OpenCartFramework\QueryBuilder\Builder;
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
use Openguru\OpenCartFramework\QueryBuilder\Table;
use Openguru\OpenCartFramework\Support\Arr;
use RuntimeException;
@@ -66,22 +67,26 @@ class ProductPrice extends BaseRule
$customerGroupId = config('oc_customer_group_id', 1);
$builder->join(
db_table('product_special') . " AS $joinAlias",
function (JoinClause $join) use ($joinAlias, $customerGroupId) {
$join
->on('products.product_id', '=', "$joinAlias.product_id")
->where("$joinAlias.customer_group_id", '=', $customerGroupId)
->whereRaw("
($joinAlias.date_start = '0000-00-00' OR $joinAlias.date_start < NOW())
AND ($joinAlias.date_end = '0000-00-00' OR $joinAlias.date_end > NOW())
")
->orderBy("$joinAlias.priority", 'ASC')
->orderBy('products.price', 'ASC')
->limit(1);
},
'left'
);
$sub = $builder->newQuery()
->select([
'ps.product_id',
'ps.price',
])
->from(db_table('product_special'), 'ps')
->where("ps.customer_group_id", '=', $customerGroupId)
->whereRaw(
"
(ps.date_start = '0000-00-00' OR ps.date_start < NOW())
AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())
"
)
->orderBy('ps.priority', 'ASC')
->orderBy('ps.price', 'ASC')
->limit(1);
$builder->join(new Table($sub, $joinAlias), function (JoinClause $join) use ($joinAlias) {
$join->on('products.product_id', '=', "$joinAlias.product_id");
}, Builder::JOIN_TYPE_LEFT);
$column = new RawExpression("COALESCE($joinAlias.price, products.price)");
}
@@ -103,18 +108,21 @@ class ProductPrice extends BaseRule
// если только правая граница — "меньше или равно"
if ($min === null && $max !== null) {
$builder->where($column, '<=', $max, $operand);
return;
}
// если только левая граница — "больше или равно"
if ($min !== null && $max === null) {
$builder->where($column, '>=', $min, $operand);
return;
}
// левая и правая граница равны
if ($min !== null && $max !== null && $min === $max) {
$builder->where($column, '=', $min, $operand);
return;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\FacetSearch\Filters;
namespace App\Filters;
use InvalidArgumentException;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\FacetSearch\Filters;
namespace App\Filters;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;

View File

@@ -46,11 +46,6 @@ class ProductsHandler
public function show(Request $request): JsonResponse
{
$productId = (int) $request->get('id');
$languageId = 1;
$imageWidth = 500;
$imageHeight = 500;
$imageFullWidth = 1000;
$imageFullHeight = 1000;
try {
$product = $this->productsService->getProductById($productId);

View File

@@ -3,14 +3,14 @@
namespace App\ServiceProviders;
use App\Exceptions\CustomExceptionHandler;
use App\FacetSearch\Filters\ProductAttribute;
use App\FacetSearch\Filters\ProductCategories;
use App\FacetSearch\Filters\ProductForMainPage;
use App\FacetSearch\Filters\ProductManufacturer;
use App\FacetSearch\Filters\ProductModel;
use App\FacetSearch\Filters\ProductPrice;
use App\FacetSearch\Filters\ProductQuantity;
use App\FacetSearch\Filters\ProductStatus;
use App\Filters\ProductAttribute;
use App\Filters\ProductCategories;
use App\Filters\ProductForMainPage;
use App\Filters\ProductManufacturer;
use App\Filters\ProductModel;
use App\Filters\ProductPrice;
use App\Filters\ProductQuantity;
use App\Filters\ProductStatus;
use App\Telegram\LinkCommand;
use Openguru\OpenCartFramework\Container\ServiceProvider;
use Openguru\OpenCartFramework\Contracts\ExceptionHandlerInterface;

View File

@@ -7,6 +7,7 @@ use Openguru\OpenCartFramework\QueryBuilder\Connections\MySqlConnection;
use Openguru\OpenCartFramework\QueryBuilder\Grammars\MySqlGrammar;
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
use Openguru\OpenCartFramework\QueryBuilder\Table;
use Tests\TestCase;
class BuilderTest extends TestCase
@@ -344,4 +345,157 @@ class BuilderTest extends TestCase
->toRawSql()
);
}
public function testHasJoinAlias(): void
{
$this->builder
->select(['id'])
->from('table1')
->join('table2 AS tbl_alias', function (JoinClause $join) {
return $join->on('table1.id', '=', 'tbl_alias.id');
})
->toRawSql();
$this->assertStringContainsString('AS tbl_alias', $this->builder->toRawSql());
}
public function testHasJoinAliasWithTableClass(): void
{
$this->builder
->select(['id'])
->from('table1')
->join(new Table('table2', 'tbl_alias'), function (JoinClause $join) {
return $join->on('table1.id', '=', 'tbl_alias.id');
})
->toRawSql();
$this->assertTrue($this->builder->hasJoinAlias('tbl_alias'));
}
public function testHasJoinHasAliasWithTableClass(): void
{
$this->builder
->select(['id'])
->from('table1')
->join(new Table('table2', 'tbl_alias'), function (JoinClause $join) {
return $join->on('table1.id', '=', 'tbl_alias.id');
})
->toRawSql();
$this->assertTrue($this->builder->hasJoinAlias('tbl_alias'));
}
public function testJoinWithAlias(): void
{
$this->assertEquals(
/** @lang text */
'SELECT * FROM t1 INNER JOIN t2 AS t2_alias ON t1.key = t2_alias.key AND t1.foo IS NOT NULL OR t2_alias.bar <> ?',
$this->builder
->from('t1')
->join('t2 AS t2_alias', function (JoinClause $join) {
$join->on('t1.key', '=', 't2_alias.key')
->whereNotNull('t1.foo')
->where('t2_alias.bar', '<>', 'value', 'or');
})
->toSql()
);
}
public function testJoinTableClassWithAlias(): void
{
$this->assertEquals(
/** @lang text */
'SELECT * FROM t1 INNER JOIN t2 AS t2_alias ON t1.key = t2_alias.key AND t1.foo IS NOT NULL OR t2_alias.bar <> ?',
$this->builder
->from('t1')
->join(new Table('t2', 't2_alias'), function (JoinClause $join) {
$join->on('t1.key', '=', 't2_alias.key')
->whereNotNull('t1.foo')
->where('t2_alias.bar', '<>', 'value', 'or');
})
->toSql()
);
}
public function testJoinTableClass(): void
{
$this->assertEquals(
/** @lang text */ 'SELECT * FROM t1 INNER JOIN t2 ON t1.key = t2.key AND t1.foo IS NOT NULL OR t2.bar <> ?',
$this->builder
->from('t1')
->join(new Table('t2'), function (JoinClause $join) {
$join->on('t1.key', '=', 't2.key')
->whereNotNull('t1.foo')
->where('t2.bar', '<>', 'value', 'or');
})
->toSql()
);
}
public function testJoinSub(): void
{
$sub = $this->builder->newQuery()
->select(['id', 'name'])
->from('table_2')
->limit(1);
$query = $this->builder->newQuery()
->select([
'table_1.id',
'sub_alias.name',
])
->from('table_1')
->join(new Table($sub, 'sub_alias'), function (JoinClause $join) {
$join->on('table_1.id', '=', 'sub_alias.id');
});
$expected = "SELECT table_1.id, sub_alias.name FROM table_1 INNER JOIN (SELECT id, name FROM table_2 LIMIT 1) AS sub_alias ON table_1.id = sub_alias.id";
$this->assertEquals($expected, $query->toRawSql());
}
public function testLeftJoinSub(): void
{
$sub = $this->builder->newQuery()
->select(['id', 'name'])
->from('table_2')
->limit(1);
$query = $this->builder->newQuery()
->select([
'table_1.id',
'sub_alias.name',
])
->from('table_1')
->leftJoin(new Table($sub, 'sub_alias'), function (JoinClause $join) {
$join->on('table_1.id', '=', 'sub_alias.id');
});
$expected = "SELECT table_1.id, sub_alias.name FROM table_1 LEFT JOIN (SELECT id, name FROM table_2 LIMIT 1) AS sub_alias ON table_1.id = sub_alias.id";
$this->assertEquals($expected, $query->toRawSql());
}
public function testJoinSubWithBindings(): void
{
$sub = $this->builder->newQuery()
->select(['id', 'name'])
->from('table_2')
->where('foo', '=', 'bar')
->limit(1);
$query = $this->builder->newQuery()
->select([
'table_1.id',
'sub_alias.name',
])
->from('table_1')
->join(new Table($sub, 'sub_alias'), function (JoinClause $join) {
$join->on('table_1.id', '=', 'sub_alias.id');
});
$expected = "SELECT table_1.id, sub_alias.name FROM table_1 INNER JOIN (SELECT id, name FROM table_2 WHERE foo = 'bar' LIMIT 1) AS sub_alias ON table_1.id = sub_alias.id";
$this->assertEquals($expected, $query->toRawSql());
}
}

View File

@@ -2,14 +2,14 @@
namespace Tests\Unit;
use App\FacetSearch\Filters\ProductAttribute;
use App\FacetSearch\Filters\ProductCategories;
use App\FacetSearch\Filters\ProductForMainPage;
use App\FacetSearch\Filters\ProductManufacturer;
use App\FacetSearch\Filters\ProductModel;
use App\FacetSearch\Filters\ProductPrice;
use App\FacetSearch\Filters\ProductQuantity;
use App\FacetSearch\Filters\ProductStatus;
use App\Filters\ProductAttribute;
use App\Filters\ProductCategories;
use App\Filters\ProductForMainPage;
use App\Filters\ProductManufacturer;
use App\Filters\ProductModel;
use App\Filters\ProductPrice;
use App\Filters\ProductQuantity;
use App\Filters\ProductStatus;
use DirectoryIterator;
use InvalidArgumentException;
use JsonException;
@@ -60,8 +60,6 @@ class CriteriaBuilderTest extends TestCase
$mysqlConnection = new MySqlConnection($this->getPdoMock());
$application->boot();
$e = config('mainpage_products');
$application->bind(ConnectionInterface::class, function () use ($mysqlConnection) {
return $mysqlConnection;
});

View File

@@ -2,7 +2,7 @@
namespace Tests\Unit;
use App\FacetSearch\Filters\ProductModel;
use App\Filters\ProductModel;
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
use Openguru\OpenCartFramework\CriteriaBuilder\RuleSerializer;
use Tests\TestCase;

View File

@@ -0,0 +1,55 @@
<?php
namespace Tests\Unit;
use InvalidArgumentException;
use Openguru\OpenCartFramework\QueryBuilder\Builder;
use Openguru\OpenCartFramework\QueryBuilder\Connections\MySqlConnection;
use Openguru\OpenCartFramework\QueryBuilder\Grammars\MySqlGrammar;
use Openguru\OpenCartFramework\QueryBuilder\Table;
use Tests\TestCase;
class TableTest extends TestCase
{
public function testGetTableString(): void
{
$table = new Table('table1');
$this->assertEquals('table1', $table->getTable());
}
public function testToStringSub(): void
{
$connection = new MySqlConnection($this->getPdoMock());
$builder = new Builder($connection, new MySqlGrammar());
$subQuery = $builder->newQuery()
->select(['id'])
->from('table1');
$table = new Table($subQuery, 'tbl_alias');
$this->assertEquals('(SELECT id FROM table1) AS tbl_alias', (string) $table);
}
public function testThrowsExceptionForSubWithoutAlias(): void
{
$this->expectException(InvalidArgumentException::class);
$connection = new MySqlConnection($this->getPdoMock());
$builder = new Builder($connection, new MySqlGrammar());
$subQuery = $builder->newQuery()
->select(['id'])
->from('table1');
new Table($subQuery);
}
public function testGetAlias(): void
{
$table = new Table('table1', 'alias');
$this->assertEquals('alias', $table->getAlias());
}
}

View File

@@ -10,6 +10,4 @@ SELECT
FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
WHERE
products.product_id IN (1, 2, 3)
AND product_description.language_id = 1

View File

@@ -10,6 +10,4 @@ SELECT
FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
ORDER BY
products.date_modified DESC
AND product_description.language_id = 1

View File

@@ -10,6 +10,4 @@ SELECT
FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
ORDER BY
products.viewed DESC
AND product_description.language_id = 1

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_4bf5415bae7c037731801559d0410697 ON products.product_id = product_specials_4bf5415bae7c037731801559d0410697.product_id
AND product_specials_4bf5415bae7c037731801559d0410697.customer_group_id = 1
AND (
product_specials_4bf5415bae7c037731801559d0410697.date_start = '0000-00-00'
OR product_specials_4bf5415bae7c037731801559d0410697.date_start < NOW()
)
AND (
product_specials_4bf5415bae7c037731801559d0410697.date_end = '0000-00-00'
OR product_specials_4bf5415bae7c037731801559d0410697.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_4bf5415bae7c037731801559d0410697 ON products.product_id = product_specials_4bf5415bae7c037731801559d0410697.product_id
WHERE
COALESCE(
product_specials_4bf5415bae7c037731801559d0410697.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_f1ca65a396fc2e41a23a3661b84d1519 ON products.product_id = product_specials_f1ca65a396fc2e41a23a3661b84d1519.product_id
AND product_specials_f1ca65a396fc2e41a23a3661b84d1519.customer_group_id = 1
AND (
product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_start = '0000-00-00'
OR product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_start < NOW()
)
AND (
product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_end = '0000-00-00'
OR product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_f1ca65a396fc2e41a23a3661b84d1519 ON products.product_id = product_specials_f1ca65a396fc2e41a23a3661b84d1519.product_id
WHERE
COALESCE(
product_specials_f1ca65a396fc2e41a23a3661b84d1519.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_f0c4ece67502916e844720b12abc54a9 ON products.product_id = product_specials_f0c4ece67502916e844720b12abc54a9.product_id
AND product_specials_f0c4ece67502916e844720b12abc54a9.customer_group_id = 1
AND (
product_specials_f0c4ece67502916e844720b12abc54a9.date_start = '0000-00-00'
OR product_specials_f0c4ece67502916e844720b12abc54a9.date_start < NOW()
)
AND (
product_specials_f0c4ece67502916e844720b12abc54a9.date_end = '0000-00-00'
OR product_specials_f0c4ece67502916e844720b12abc54a9.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_f0c4ece67502916e844720b12abc54a9 ON products.product_id = product_specials_f0c4ece67502916e844720b12abc54a9.product_id
WHERE
COALESCE(
product_specials_f0c4ece67502916e844720b12abc54a9.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_5173bd7b8335ab5a9f4e37227d0c317f ON products.product_id = product_specials_5173bd7b8335ab5a9f4e37227d0c317f.product_id
AND product_specials_5173bd7b8335ab5a9f4e37227d0c317f.customer_group_id = 1
AND (
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_start = '0000-00-00'
OR product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_start < NOW()
)
AND (
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_end = '0000-00-00'
OR product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_5173bd7b8335ab5a9f4e37227d0c317f ON products.product_id = product_specials_5173bd7b8335ab5a9f4e37227d0c317f.product_id
WHERE
COALESCE(
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_7b934dfdfc5b809270875934c10acc06 ON products.product_id = product_specials_7b934dfdfc5b809270875934c10acc06.product_id
AND product_specials_7b934dfdfc5b809270875934c10acc06.customer_group_id = 1
AND (
product_specials_7b934dfdfc5b809270875934c10acc06.date_start = '0000-00-00'
OR product_specials_7b934dfdfc5b809270875934c10acc06.date_start < NOW()
)
AND (
product_specials_7b934dfdfc5b809270875934c10acc06.date_end = '0000-00-00'
OR product_specials_7b934dfdfc5b809270875934c10acc06.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_7b934dfdfc5b809270875934c10acc06 ON products.product_id = product_specials_7b934dfdfc5b809270875934c10acc06.product_id
WHERE
COALESCE(
product_specials_7b934dfdfc5b809270875934c10acc06.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
)
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
WHERE
COALESCE(
product_specials_51a33d8bcfeece60de797c18e3800075.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_7de8997be994ada47d62cdfe2b7369c9 ON products.product_id = product_specials_7de8997be994ada47d62cdfe2b7369c9.product_id
AND product_specials_7de8997be994ada47d62cdfe2b7369c9.customer_group_id = 1
AND (
product_specials_7de8997be994ada47d62cdfe2b7369c9.date_start = '0000-00-00'
OR product_specials_7de8997be994ada47d62cdfe2b7369c9.date_start < NOW()
)
AND (
product_specials_7de8997be994ada47d62cdfe2b7369c9.date_end = '0000-00-00'
OR product_specials_7de8997be994ada47d62cdfe2b7369c9.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_7de8997be994ada47d62cdfe2b7369c9 ON products.product_id = product_specials_7de8997be994ada47d62cdfe2b7369c9.product_id
WHERE
COALESCE(
product_specials_7de8997be994ada47d62cdfe2b7369c9.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_78ccac1dc1d86997e6eac0613f2eb5f3 ON products.product_id = product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.product_id
AND product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.customer_group_id = 1
AND (
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_start = '0000-00-00'
OR product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_start < NOW()
)
AND (
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_end = '0000-00-00'
OR product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_78ccac1dc1d86997e6eac0613f2eb5f3 ON products.product_id = product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.product_id
WHERE
COALESCE(
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_5816f1e65a3d296a26635f070d0439bc ON products.product_id = product_specials_5816f1e65a3d296a26635f070d0439bc.product_id
AND product_specials_5816f1e65a3d296a26635f070d0439bc.customer_group_id = 1
AND (
product_specials_5816f1e65a3d296a26635f070d0439bc.date_start = '0000-00-00'
OR product_specials_5816f1e65a3d296a26635f070d0439bc.date_start < NOW()
)
AND (
product_specials_5816f1e65a3d296a26635f070d0439bc.date_end = '0000-00-00'
OR product_specials_5816f1e65a3d296a26635f070d0439bc.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_5816f1e65a3d296a26635f070d0439bc ON products.product_id = product_specials_5816f1e65a3d296a26635f070d0439bc.product_id
WHERE
COALESCE(
product_specials_5816f1e65a3d296a26635f070d0439bc.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
)
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
WHERE
COALESCE(
product_specials_51a33d8bcfeece60de797c18e3800075.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
)
AND (
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
WHERE
COALESCE(
product_specials_51a33d8bcfeece60de797c18e3800075.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_cf0f856fa900f18f5c8c0a57357532f5 ON products.product_id = product_specials_cf0f856fa900f18f5c8c0a57357532f5.product_id
AND product_specials_cf0f856fa900f18f5c8c0a57357532f5.customer_group_id = 1
AND (
product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_start = '0000-00-00'
OR product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_start < NOW()
)
AND (
product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_end = '0000-00-00'
OR product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_cf0f856fa900f18f5c8c0a57357532f5 ON products.product_id = product_specials_cf0f856fa900f18f5c8c0a57357532f5.product_id
WHERE
COALESCE(
product_specials_cf0f856fa900f18f5c8c0a57357532f5.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_08e0a0248dc92591ae55fdd966728ba0 ON products.product_id = product_specials_08e0a0248dc92591ae55fdd966728ba0.product_id
AND product_specials_08e0a0248dc92591ae55fdd966728ba0.customer_group_id = 1
AND (
product_specials_08e0a0248dc92591ae55fdd966728ba0.date_start = '0000-00-00'
OR product_specials_08e0a0248dc92591ae55fdd966728ba0.date_start < NOW()
)
AND (
product_specials_08e0a0248dc92591ae55fdd966728ba0.date_end = '0000-00-00'
OR product_specials_08e0a0248dc92591ae55fdd966728ba0.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_08e0a0248dc92591ae55fdd966728ba0 ON products.product_id = product_specials_08e0a0248dc92591ae55fdd966728ba0.product_id
WHERE
COALESCE(
product_specials_08e0a0248dc92591ae55fdd966728ba0.price,

View File

@@ -11,16 +11,28 @@ FROM
oc_product AS products
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
AND product_description.language_id = 1
LEFT JOIN oc_product_special AS product_specials_47d71067324729b89b13414a6ea869e0 ON products.product_id = product_specials_47d71067324729b89b13414a6ea869e0.product_id
AND product_specials_47d71067324729b89b13414a6ea869e0.customer_group_id = 1
AND (
product_specials_47d71067324729b89b13414a6ea869e0.date_start = '0000-00-00'
OR product_specials_47d71067324729b89b13414a6ea869e0.date_start < NOW()
)
AND (
product_specials_47d71067324729b89b13414a6ea869e0.date_end = '0000-00-00'
OR product_specials_47d71067324729b89b13414a6ea869e0.date_end > NOW()
)
LEFT JOIN (
SELECT
ps.product_id,
ps.price
FROM
oc_product_special AS ps
WHERE
ps.customer_group_id = 1
AND (
ps.date_start = '0000-00-00'
OR ps.date_start < NOW()
)
AND (
ps.date_end = '0000-00-00'
OR ps.date_end > NOW()
)
ORDER BY
ps.priority ASC,
ps.price ASC
LIMIT
1
) AS product_specials_47d71067324729b89b13414a6ea869e0 ON products.product_id = product_specials_47d71067324729b89b13414a6ea869e0.product_id
WHERE
COALESCE(
product_specials_47d71067324729b89b13414a6ea869e0.price,