wip: product filters
This commit is contained in:
@@ -10,6 +10,10 @@ use InvalidArgumentException;
|
|||||||
|
|
||||||
class Builder
|
class Builder
|
||||||
{
|
{
|
||||||
|
public const JOIN_TYPE_LEFT = 'LEFT';
|
||||||
|
public const JOIN_TYPE_INNER = 'INNER';
|
||||||
|
public const JOIN_TYPE_RIGHT = 'RIGHT';
|
||||||
|
|
||||||
private $connection;
|
private $connection;
|
||||||
private $grammar;
|
private $grammar;
|
||||||
|
|
||||||
@@ -251,7 +255,7 @@ class Builder
|
|||||||
public function toRawSql(): string
|
public function toRawSql(): string
|
||||||
{
|
{
|
||||||
return $this->substituteBindingsIntoRawSql(
|
return $this->substituteBindingsIntoRawSql(
|
||||||
$this->toSql(),
|
str_replace("\n", ' ', $this->toSql()),
|
||||||
$this->getBindings()
|
$this->getBindings()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -362,9 +366,15 @@ class Builder
|
|||||||
Utils::dd($this->toSql(), $this->getBindings());
|
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);
|
$joinClosure($joinClause);
|
||||||
|
|
||||||
@@ -374,9 +384,14 @@ class Builder
|
|||||||
return $this;
|
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
|
public function getConnection(): ConnectionInterface
|
||||||
|
|||||||
@@ -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 : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
@@ -10,6 +10,7 @@ use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
|||||||
use Openguru\OpenCartFramework\QueryBuilder\Builder;
|
use Openguru\OpenCartFramework\QueryBuilder\Builder;
|
||||||
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
|
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
|
||||||
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
|
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
|
||||||
|
use Openguru\OpenCartFramework\QueryBuilder\Table;
|
||||||
use Openguru\OpenCartFramework\Support\Arr;
|
use Openguru\OpenCartFramework\Support\Arr;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@@ -66,22 +67,26 @@ class ProductPrice extends BaseRule
|
|||||||
|
|
||||||
$customerGroupId = config('oc_customer_group_id', 1);
|
$customerGroupId = config('oc_customer_group_id', 1);
|
||||||
|
|
||||||
$builder->join(
|
$sub = $builder->newQuery()
|
||||||
db_table('product_special') . " AS $joinAlias",
|
->select([
|
||||||
function (JoinClause $join) use ($joinAlias, $customerGroupId) {
|
'ps.product_id',
|
||||||
$join
|
'ps.price',
|
||||||
->on('products.product_id', '=', "$joinAlias.product_id")
|
])
|
||||||
->where("$joinAlias.customer_group_id", '=', $customerGroupId)
|
->from(db_table('product_special'), 'ps')
|
||||||
->whereRaw("
|
->where("ps.customer_group_id", '=', $customerGroupId)
|
||||||
($joinAlias.date_start = '0000-00-00' OR $joinAlias.date_start < NOW())
|
->whereRaw(
|
||||||
AND ($joinAlias.date_end = '0000-00-00' OR $joinAlias.date_end > NOW())
|
"
|
||||||
")
|
(ps.date_start = '0000-00-00' OR ps.date_start < NOW())
|
||||||
->orderBy("$joinAlias.priority", 'ASC')
|
AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())
|
||||||
->orderBy('products.price', 'ASC')
|
"
|
||||||
|
)
|
||||||
|
->orderBy('ps.priority', 'ASC')
|
||||||
|
->orderBy('ps.price', 'ASC')
|
||||||
->limit(1);
|
->limit(1);
|
||||||
},
|
|
||||||
'left'
|
$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)");
|
$column = new RawExpression("COALESCE($joinAlias.price, products.price)");
|
||||||
}
|
}
|
||||||
@@ -103,18 +108,21 @@ class ProductPrice extends BaseRule
|
|||||||
// если только правая граница — "меньше или равно"
|
// если только правая граница — "меньше или равно"
|
||||||
if ($min === null && $max !== null) {
|
if ($min === null && $max !== null) {
|
||||||
$builder->where($column, '<=', $max, $operand);
|
$builder->where($column, '<=', $max, $operand);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// если только левая граница — "больше или равно"
|
// если только левая граница — "больше или равно"
|
||||||
if ($min !== null && $max === null) {
|
if ($min !== null && $max === null) {
|
||||||
$builder->where($column, '>=', $min, $operand);
|
$builder->where($column, '>=', $min, $operand);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// левая и правая граница равны
|
// левая и правая граница равны
|
||||||
if ($min !== null && $max !== null && $min === $max) {
|
if ($min !== null && $max !== null && $min === $max) {
|
||||||
$builder->where($column, '=', $min, $operand);
|
$builder->where($column, '=', $min, $operand);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\FacetSearch\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Rules\BaseRule;
|
||||||
@@ -46,11 +46,6 @@ class ProductsHandler
|
|||||||
public function show(Request $request): JsonResponse
|
public function show(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$productId = (int) $request->get('id');
|
$productId = (int) $request->get('id');
|
||||||
$languageId = 1;
|
|
||||||
$imageWidth = 500;
|
|
||||||
$imageHeight = 500;
|
|
||||||
$imageFullWidth = 1000;
|
|
||||||
$imageFullHeight = 1000;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$product = $this->productsService->getProductById($productId);
|
$product = $this->productsService->getProductById($productId);
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
namespace App\ServiceProviders;
|
namespace App\ServiceProviders;
|
||||||
|
|
||||||
use App\Exceptions\CustomExceptionHandler;
|
use App\Exceptions\CustomExceptionHandler;
|
||||||
use App\FacetSearch\Filters\ProductAttribute;
|
use App\Filters\ProductAttribute;
|
||||||
use App\FacetSearch\Filters\ProductCategories;
|
use App\Filters\ProductCategories;
|
||||||
use App\FacetSearch\Filters\ProductForMainPage;
|
use App\Filters\ProductForMainPage;
|
||||||
use App\FacetSearch\Filters\ProductManufacturer;
|
use App\Filters\ProductManufacturer;
|
||||||
use App\FacetSearch\Filters\ProductModel;
|
use App\Filters\ProductModel;
|
||||||
use App\FacetSearch\Filters\ProductPrice;
|
use App\Filters\ProductPrice;
|
||||||
use App\FacetSearch\Filters\ProductQuantity;
|
use App\Filters\ProductQuantity;
|
||||||
use App\FacetSearch\Filters\ProductStatus;
|
use App\Filters\ProductStatus;
|
||||||
use App\Telegram\LinkCommand;
|
use App\Telegram\LinkCommand;
|
||||||
use Openguru\OpenCartFramework\Container\ServiceProvider;
|
use Openguru\OpenCartFramework\Container\ServiceProvider;
|
||||||
use Openguru\OpenCartFramework\Contracts\ExceptionHandlerInterface;
|
use Openguru\OpenCartFramework\Contracts\ExceptionHandlerInterface;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Openguru\OpenCartFramework\QueryBuilder\Connections\MySqlConnection;
|
|||||||
use Openguru\OpenCartFramework\QueryBuilder\Grammars\MySqlGrammar;
|
use Openguru\OpenCartFramework\QueryBuilder\Grammars\MySqlGrammar;
|
||||||
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
|
use Openguru\OpenCartFramework\QueryBuilder\JoinClause;
|
||||||
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
|
use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
|
||||||
|
use Openguru\OpenCartFramework\QueryBuilder\Table;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class BuilderTest extends TestCase
|
class BuilderTest extends TestCase
|
||||||
@@ -344,4 +345,157 @@ class BuilderTest extends TestCase
|
|||||||
->toRawSql()
|
->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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use App\FacetSearch\Filters\ProductAttribute;
|
use App\Filters\ProductAttribute;
|
||||||
use App\FacetSearch\Filters\ProductCategories;
|
use App\Filters\ProductCategories;
|
||||||
use App\FacetSearch\Filters\ProductForMainPage;
|
use App\Filters\ProductForMainPage;
|
||||||
use App\FacetSearch\Filters\ProductManufacturer;
|
use App\Filters\ProductManufacturer;
|
||||||
use App\FacetSearch\Filters\ProductModel;
|
use App\Filters\ProductModel;
|
||||||
use App\FacetSearch\Filters\ProductPrice;
|
use App\Filters\ProductPrice;
|
||||||
use App\FacetSearch\Filters\ProductQuantity;
|
use App\Filters\ProductQuantity;
|
||||||
use App\FacetSearch\Filters\ProductStatus;
|
use App\Filters\ProductStatus;
|
||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
@@ -60,8 +60,6 @@ class CriteriaBuilderTest extends TestCase
|
|||||||
$mysqlConnection = new MySqlConnection($this->getPdoMock());
|
$mysqlConnection = new MySqlConnection($this->getPdoMock());
|
||||||
$application->boot();
|
$application->boot();
|
||||||
|
|
||||||
$e = config('mainpage_products');
|
|
||||||
|
|
||||||
$application->bind(ConnectionInterface::class, function () use ($mysqlConnection) {
|
$application->bind(ConnectionInterface::class, function () use ($mysqlConnection) {
|
||||||
return $mysqlConnection;
|
return $mysqlConnection;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use App\FacetSearch\Filters\ProductModel;
|
use App\Filters\ProductModel;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
use Openguru\OpenCartFramework\CriteriaBuilder\Criterion;
|
||||||
use Openguru\OpenCartFramework\CriteriaBuilder\RuleSerializer;
|
use Openguru\OpenCartFramework\CriteriaBuilder\RuleSerializer;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|||||||
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,5 +11,3 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
WHERE
|
|
||||||
products.product_id IN (1, 2, 3)
|
|
||||||
@@ -11,5 +11,3 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
ORDER BY
|
|
||||||
products.date_modified DESC
|
|
||||||
@@ -11,5 +11,3 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
ORDER BY
|
|
||||||
products.viewed DESC
|
|
||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_4bf5415bae7c037731801559d0410697 ON products.product_id = product_specials_4bf5415bae7c037731801559d0410697.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_4bf5415bae7c037731801559d0410697.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_4bf5415bae7c037731801559d0410697.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_4bf5415bae7c037731801559d0410697.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_4bf5415bae7c037731801559d0410697.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_4bf5415bae7c037731801559d0410697.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_4bf5415bae7c037731801559d0410697.price,
|
product_specials_4bf5415bae7c037731801559d0410697.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_f1ca65a396fc2e41a23a3661b84d1519 ON products.product_id = product_specials_f1ca65a396fc2e41a23a3661b84d1519.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_f1ca65a396fc2e41a23a3661b84d1519.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_f1ca65a396fc2e41a23a3661b84d1519.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_f1ca65a396fc2e41a23a3661b84d1519.price,
|
product_specials_f1ca65a396fc2e41a23a3661b84d1519.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_f0c4ece67502916e844720b12abc54a9 ON products.product_id = product_specials_f0c4ece67502916e844720b12abc54a9.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_f0c4ece67502916e844720b12abc54a9.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_f0c4ece67502916e844720b12abc54a9.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_f0c4ece67502916e844720b12abc54a9.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_f0c4ece67502916e844720b12abc54a9.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_f0c4ece67502916e844720b12abc54a9.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_f0c4ece67502916e844720b12abc54a9.price,
|
product_specials_f0c4ece67502916e844720b12abc54a9.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_5173bd7b8335ab5a9f4e37227d0c317f ON products.product_id = product_specials_5173bd7b8335ab5a9f4e37227d0c317f.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_5173bd7b8335ab5a9f4e37227d0c317f.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_5173bd7b8335ab5a9f4e37227d0c317f.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.price,
|
product_specials_5173bd7b8335ab5a9f4e37227d0c317f.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_7b934dfdfc5b809270875934c10acc06 ON products.product_id = product_specials_7b934dfdfc5b809270875934c10acc06.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_7b934dfdfc5b809270875934c10acc06.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_7b934dfdfc5b809270875934c10acc06.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_7b934dfdfc5b809270875934c10acc06.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_7b934dfdfc5b809270875934c10acc06.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_7b934dfdfc5b809270875934c10acc06.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_7b934dfdfc5b809270875934c10acc06.price,
|
product_specials_7b934dfdfc5b809270875934c10acc06.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_7de8997be994ada47d62cdfe2b7369c9 ON products.product_id = product_specials_7de8997be994ada47d62cdfe2b7369c9.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_7de8997be994ada47d62cdfe2b7369c9.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_7de8997be994ada47d62cdfe2b7369c9.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_7de8997be994ada47d62cdfe2b7369c9.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_7de8997be994ada47d62cdfe2b7369c9.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_7de8997be994ada47d62cdfe2b7369c9.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_7de8997be994ada47d62cdfe2b7369c9.price,
|
product_specials_7de8997be994ada47d62cdfe2b7369c9.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_78ccac1dc1d86997e6eac0613f2eb5f3 ON products.product_id = product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.price,
|
product_specials_78ccac1dc1d86997e6eac0613f2eb5f3.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_5816f1e65a3d296a26635f070d0439bc ON products.product_id = product_specials_5816f1e65a3d296a26635f070d0439bc.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_5816f1e65a3d296a26635f070d0439bc.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_5816f1e65a3d296a26635f070d0439bc.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_5816f1e65a3d296a26635f070d0439bc.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_5816f1e65a3d296a26635f070d0439bc.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_5816f1e65a3d296a26635f070d0439bc.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_5816f1e65a3d296a26635f070d0439bc.price,
|
product_specials_5816f1e65a3d296a26635f070d0439bc.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_51a33d8bcfeece60de797c18e3800075 ON products.product_id = product_specials_51a33d8bcfeece60de797c18e3800075.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_51a33d8bcfeece60de797c18e3800075.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_51a33d8bcfeece60de797c18e3800075.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
product_specials_51a33d8bcfeece60de797c18e3800075.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_cf0f856fa900f18f5c8c0a57357532f5 ON products.product_id = product_specials_cf0f856fa900f18f5c8c0a57357532f5.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_cf0f856fa900f18f5c8c0a57357532f5.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_cf0f856fa900f18f5c8c0a57357532f5.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_cf0f856fa900f18f5c8c0a57357532f5.price,
|
product_specials_cf0f856fa900f18f5c8c0a57357532f5.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_08e0a0248dc92591ae55fdd966728ba0 ON products.product_id = product_specials_08e0a0248dc92591ae55fdd966728ba0.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_08e0a0248dc92591ae55fdd966728ba0.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_08e0a0248dc92591ae55fdd966728ba0.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_08e0a0248dc92591ae55fdd966728ba0.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_08e0a0248dc92591ae55fdd966728ba0.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_08e0a0248dc92591ae55fdd966728ba0.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_08e0a0248dc92591ae55fdd966728ba0.price,
|
product_specials_08e0a0248dc92591ae55fdd966728ba0.price,
|
||||||
|
|||||||
@@ -11,16 +11,28 @@ FROM
|
|||||||
oc_product AS products
|
oc_product AS products
|
||||||
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
INNER JOIN oc_product_description AS product_description ON products.product_id = product_description.product_id
|
||||||
AND product_description.language_id = 1
|
AND product_description.language_id = 1
|
||||||
LEFT JOIN oc_product_special AS product_specials_47d71067324729b89b13414a6ea869e0 ON products.product_id = product_specials_47d71067324729b89b13414a6ea869e0.product_id
|
LEFT JOIN (
|
||||||
AND product_specials_47d71067324729b89b13414a6ea869e0.customer_group_id = 1
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price
|
||||||
|
FROM
|
||||||
|
oc_product_special AS ps
|
||||||
|
WHERE
|
||||||
|
ps.customer_group_id = 1
|
||||||
AND (
|
AND (
|
||||||
product_specials_47d71067324729b89b13414a6ea869e0.date_start = '0000-00-00'
|
ps.date_start = '0000-00-00'
|
||||||
OR product_specials_47d71067324729b89b13414a6ea869e0.date_start < NOW()
|
OR ps.date_start < NOW()
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
product_specials_47d71067324729b89b13414a6ea869e0.date_end = '0000-00-00'
|
ps.date_end = '0000-00-00'
|
||||||
OR product_specials_47d71067324729b89b13414a6ea869e0.date_end > NOW()
|
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
|
WHERE
|
||||||
COALESCE(
|
COALESCE(
|
||||||
product_specials_47d71067324729b89b13414a6ea869e0.price,
|
product_specials_47d71067324729b89b13414a6ea869e0.price,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container h-full">
|
<div class="app-container h-full">
|
||||||
|
<header class="app-header w-full" v-if="platform === 'ios'"></header>
|
||||||
|
|
||||||
|
<section class="safe-top">
|
||||||
<FullscreenViewport v-if="platform === 'ios' || platform === 'android'"/>
|
<FullscreenViewport v-if="platform === 'ios' || platform === 'android'"/>
|
||||||
<RouterView v-slot="{ Component, route }">
|
<RouterView v-slot="{ Component, route }">
|
||||||
<Transition name="route" appear>
|
<Transition name="route" appear>
|
||||||
@@ -7,6 +10,7 @@
|
|||||||
</Transition>
|
</Transition>
|
||||||
</RouterView>
|
</RouterView>
|
||||||
<CartButton v-if="settings.store_enabled"/>
|
<CartButton v-if="settings.store_enabled"/>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -50,3 +54,21 @@ watch(
|
|||||||
{immediate: true}
|
{immediate: true}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* route transitions */
|
||||||
|
.route-enter-active,
|
||||||
|
.route-leave-active {
|
||||||
|
transition: opacity 0.25s ease, transform 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.route-enter-from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.route-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div v-if="isCartBtnShow" class="fixed right-2 bottom-30 z-50 opacity-90">
|
<div v-if="isCartBtnShow" class="fixed right-2 bottom-30 z-50 opacity-90">
|
||||||
<div class="indicator">
|
<div class="indicator">
|
||||||
<span class="indicator-item indicator-top indicator-start badge badge-secondary">{{ cart.productsCount }}</span>
|
<span class="indicator-item indicator-top indicator-start badge badge-secondary">{{ cart.productsCount }}</span>
|
||||||
<button class="btn btn-primary btn-lg btn-circle" @click="openCart">
|
<button class="btn btn-primary btn-xl btn-circle" @click="openCart">
|
||||||
<span v-if="cart.isLoading" class="loading loading-spinner"></span>
|
<span v-if="cart.isLoading" class="loading loading-spinner"></span>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
v-for="category in categoriesStore.topCategories"
|
v-for="category in categoriesStore.topCategories"
|
||||||
class="btn btn-md max-w-[12rem]"
|
class="btn btn-md max-w-[12rem]"
|
||||||
:to="{name: 'product.categories.show', params: {category_id: category.id}}"
|
:to="{name: 'product.categories.show', params: {category_id: category.id}}"
|
||||||
|
@click="onCategoryClick"
|
||||||
>
|
>
|
||||||
<span class="overflow-hidden text-ellipsis whitespace-nowrap">{{ category.name }}</span>
|
<span class="overflow-hidden text-ellipsis whitespace-nowrap">{{ category.name }}</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
@@ -20,4 +21,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {useCategoriesStore} from "@/stores/CategoriesStore.js";
|
import {useCategoriesStore} from "@/stores/CategoriesStore.js";
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
|
|
||||||
|
function onCategoryClick() {
|
||||||
|
window.Telegram.WebApp.HapticFeedback.impactOccurred('soft');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="z-index: 99999" class="fixed top-0 left-0 w-full h-full bg-base-100">
|
<div style="z-index: 99999" class="fixed left-0 w-full h-full bg-base-100 top-0">
|
||||||
<div class="flex flex-col items-center justify-center h-full">
|
<div class="flex flex-col items-center justify-center h-full">
|
||||||
<span class="loading loading-infinity loading-xl"></span>
|
<span class="loading loading-infinity loading-xl"></span>
|
||||||
<h1>{{ text }}</h1>
|
<h1>{{ text }}</h1>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="search-wrapper px-5 w-full">
|
<div class="search-wrapper w-full">
|
||||||
<label class="input w-full">
|
<label class="input w-full">
|
||||||
<svg class="h-[1em] opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg class="h-[1em] opacity-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<g
|
<g
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<input
|
<input
|
||||||
readonly
|
readonly
|
||||||
class="grow input-lg"
|
class="grow input-lg w-full"
|
||||||
placeholder="Поиск по магазину"
|
placeholder="Поиск по магазину"
|
||||||
@click="showSearchPage"
|
@click="showSearchPage"
|
||||||
/>
|
/>
|
||||||
@@ -32,6 +32,7 @@ const router = useRouter();
|
|||||||
function showSearchPage() {
|
function showSearchPage() {
|
||||||
router.push({name: 'search'});
|
router.push({name: 'search'});
|
||||||
useSearchStore().reset();
|
useSearchStore().reset();
|
||||||
|
window.Telegram.WebApp.HapticFeedback.impactOccurred('medium');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const useSettingsStore = defineStore('settings', {
|
|||||||
'--product_list_title_max_lines': 2,
|
'--product_list_title_max_lines': 2,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
noMoreProductsMessage: '🔚 Ну всё, разгрузили всё, что было. Даже кладовщика разбудить не удалось.',
|
noMoreProductsMessage: '🔚 Это всё по текущему запросу. Попробуйте уточнить фильтры или поиск.',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.app-container {
|
.app-container {
|
||||||
/*padding-top: var(--tg-safe-area-inset-top);*/
|
/*padding-top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));*/
|
||||||
padding-bottom: var(--tg-safe-area-inset-bottom);
|
padding-bottom: var(--tg-safe-area-inset-bottom);
|
||||||
padding-left: var(--tg-safe-area-inset-left);
|
padding-left: var(--tg-safe-area-inset-left);
|
||||||
padding-right: var(--tg-safe-area-inset-right);
|
padding-right: var(--tg-safe-area-inset-right);
|
||||||
@@ -40,6 +40,18 @@ html {
|
|||||||
padding-top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));
|
padding-top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-header {
|
||||||
|
z-index: 100;
|
||||||
|
position: fixed;
|
||||||
|
background: var(--color-primary);
|
||||||
|
padding-top: calc(var(--tg-content-safe-area-inset-top) + var(--tg-safe-area-inset-top));
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0px -1px 3px 1px #000000;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.swiper-pagination-bullets > .swiper-pagination-bullet {
|
.swiper-pagination-bullets > .swiper-pagination-bullet {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
color: red;
|
color: red;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="max-w-3xl mx-auto p-4 space-y-6 pb-30 safe-top">
|
<div class="max-w-3xl mx-auto p-4 space-y-6 pb-30">
|
||||||
<h2 class="text-2xl">
|
<h2 class="text-2xl">
|
||||||
Корзина
|
Корзина
|
||||||
<span v-if="cart.isLoading" class="loading loading-spinner loading-md"></span>
|
<span v-if="cart.isLoading" class="loading loading-spinner loading-md"></span>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mx-auto max-w-2xl px-4 py-4 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8 mb-5 safe-top">
|
<div class="mx-auto max-w-2xl px-4 py-4 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8 mb-5">
|
||||||
<h2 class="text-3xl mb-5">Категории</h2>
|
<h2 class="text-3xl mb-5">Категории</h2>
|
||||||
|
|
||||||
<div v-if="categoriesStore.isLoading" class="flex flex-col gap-4">
|
<div v-if="categoriesStore.isLoading" class="flex flex-col gap-4">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="max-w-3xl mx-auto space-y-6 pb-30 safe-top">
|
<div class="max-w-3xl mx-auto space-y-6 pb-30">
|
||||||
<h2 class="text-2xl text-center">
|
<h2 class="text-2xl text-center">
|
||||||
Оформление заказа
|
Оформление заказа
|
||||||
</h2>
|
</h2>
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="goodsRef" class="safe-top">
|
<div ref="goodsRef">
|
||||||
<CategoriesInline/>
|
<CategoriesInline/>
|
||||||
|
|
||||||
<div class="flex justify-between px-5">
|
<div class="px-5 fixed z-50 w-full opacity-90" style="bottom: var(--tg-safe-area-inset-bottom);">
|
||||||
<button @click="showFilters" class="btn">
|
<div class="bg-base-300 flex justify-between p-2 rounded-xl shadow-md">
|
||||||
|
<button @click="showFilters" class="btn mr-3">
|
||||||
<IconFunnel/>
|
<IconFunnel/>
|
||||||
</button>
|
</button>
|
||||||
<SearchInput/>
|
<SearchInput/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ProductsList/>
|
<ProductsList/>
|
||||||
<Filters
|
<Filters
|
||||||
@@ -28,7 +30,6 @@ import Filters from "@/components/ProductFilters/Filters.vue";
|
|||||||
import {onMounted, onUnmounted, ref} from "vue";
|
import {onMounted, onUnmounted, ref} from "vue";
|
||||||
import {useProductsStore} from "@/stores/ProductsStore.js";
|
import {useProductsStore} from "@/stores/ProductsStore.js";
|
||||||
import IconFunnel from "@/components/Icons/IconFunnel.vue";
|
import IconFunnel from "@/components/Icons/IconFunnel.vue";
|
||||||
import {useProductFiltersStore} from "@/stores/ProductFiltersStore.js";
|
|
||||||
import {FILTERS_MAIN_PAGE_DEFAULT} from "@/components/ProductFilters/filters.js";
|
import {FILTERS_MAIN_PAGE_DEFAULT} from "@/components/ProductFilters/filters.js";
|
||||||
import {useRoute} from "vue-router";
|
import {useRoute} from "vue-router";
|
||||||
|
|
||||||
@@ -39,11 +40,13 @@ const isFiltersShow = ref(false);
|
|||||||
const backButton = window.Telegram.WebApp.BackButton;
|
const backButton = window.Telegram.WebApp.BackButton;
|
||||||
|
|
||||||
function showFilters() {
|
function showFilters() {
|
||||||
|
window.Telegram.WebApp.HapticFeedback.impactOccurred('soft');
|
||||||
isFiltersShow.value = true;
|
isFiltersShow.value = true;
|
||||||
backButton.show();
|
backButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeFilters() {
|
function closeFilters() {
|
||||||
|
window.Telegram.WebApp.HapticFeedback.impactOccurred('rigid');
|
||||||
isFiltersShow.value = false;
|
isFiltersShow.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="safe-top max-w-3xl mx-auto p-4 space-y-6 pb-30 flex flex-col items-center h-full justify-center">
|
<div class="max-w-3xl mx-auto p-4 space-y-6 pb-30 flex flex-col items-center h-full justify-center">
|
||||||
<div class="flex flex-col justify-center items-center px-5">
|
<div class="flex flex-col justify-center items-center px-5">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-25 text-success">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-25 text-success">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="safe-top">
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<swiper-container ref="swiperEl" init="false">
|
<swiper-container ref="swiperEl" init="false">
|
||||||
<swiper-slide
|
<swiper-slide
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="goodsRef" class="safe-top">
|
<div ref="goodsRef">
|
||||||
|
<div class="px-5 fixed z-50 w-full opacity-90" style="bottom: var(--tg-safe-area-inset-bottom);">
|
||||||
|
<div class="bg-base-300 flex justify-between p-2 rounded-xl shadow-md">
|
||||||
<SearchInput/>
|
<SearchInput/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<ProductsList/>
|
<ProductsList/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -11,6 +15,7 @@ import SearchInput from "@/components/SearchInput.vue";
|
|||||||
import {onMounted} from "vue";
|
import {onMounted} from "vue";
|
||||||
import {useRoute} from "vue-router";
|
import {useRoute} from "vue-router";
|
||||||
import {useProductsStore} from "@/stores/ProductsStore.js";
|
import {useProductsStore} from "@/stores/ProductsStore.js";
|
||||||
|
import IconFunnel from "@/components/Icons/IconFunnel.vue";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const productsStore = useProductsStore();
|
const productsStore = useProductsStore();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="max-w-3xl mx-auto p-4 space-y-6 pb-20 safe-top">
|
<div class="max-w-3xl mx-auto p-4 space-y-6 pb-20">
|
||||||
<h2 class="text-2xl mb-3">Поиск</h2>
|
<h2 class="text-2xl mb-3">Поиск</h2>
|
||||||
|
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
|
|||||||
Reference in New Issue
Block a user