Rebate filter issue

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Gagik
Posts: 38
Joined: 05 Dec 2023, 06:58

Rebate filter issue

Post by Gagik » 07 Feb 2024, 14:43

Hello,

PHP version: 8.1
Laravel version: 10
Aimeos version: 2023.10
Environment: Linux

I want to add 'filter rebate products' case in my project.

I added a new column "rebate" in the "mshop_index_price" table. Overwriten the Index/Manager/Price/Standard.php to my extension folder and add a new key in the $searchConfig variable

'index.price:rebate' => array(
'code' => 'index.price:rebate()',
'internalcode' => ':site AND mindpr."currencyid" = $1 AND mindpr."rebate"',
'label' => 'Product price rebate, parameter(<currency id="">)',
'type' => 'float',
'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR,
'public' => false,
),

Then added a new method in the Controller\Frontend\Product\Standard file (this file I also overwriten) Method impl.. below.

public function rebate() : Iface
{
$func = $this->filter->make( 'index.price:rebate', [$this->context()->locale()->getCurrencyId()] );

$this->addExpression( $this->filter->compare( '>', $func, 0 ) );

return $this;
}

But when I call 'rebate()' method on the product controller, in the Catalog/Filter/Price/Standard file. I have the following error message.

Code: Select all

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':site AND mindpr."currencyid" = 'EUR' AND mindpr."rebate" > '0' AND ( mindpr."si' at line 6: SELECT "product.status", max("val") AS "value" FROM ( SELECT mpro."status" AS "product.status", mindpr."value" AS "val" FROM "mshop_product" mpro LEFT JOIN "mshop_index_catalog" AS mindca USE INDEX ("idx_msindca_s_ca_lt_po", "unq_msindca_p_s_cid_lt_po") ON mindca."prodid" = mpro."id" LEFT JOIN "mshop_index_price" AS mindpr USE INDEX ("unq_msindpr_pid_sid_cid", "idx_msindpr_sid_cid_val") ON mindpr."prodid" = mpro."id" WHERE ( ( mpro."siteid" IN ('','1.') ) AND ( ( mindpr."value" IS NOT NULL ) AND ( ( mpro."status" IS NOT NULL ) AND ( mindca."catid" IS NOT NULL AND mpro."instock" = 1 AND :site AND mindpr."currencyid" = 'EUR' AND mindpr."rebate" > '0' AND ( mindpr."siteid" IN ('','1.') ) AND mindpr."currencyid" = 'EUR' AND mindpr."value" IS NOT NULL ) ) ) ) GROUP BY mpro."status", mindpr."value", mpro."id" ORDER BY mpro."id" ASC LIMIT 100 OFFSET 0 ) AS list GROUP BY "product.status"

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: Rebate filter issue

Post by aimeos » 09 Feb 2024, 10:01

The ":site" placeholder isn't replaced automatically. You have to add that in the constructor of the class like here:
https://github.com/aimeos/aimeos-core/b ... hp#L69-L71
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Gagik
Posts: 38
Joined: 05 Dec 2023, 06:58

Re: Rebate filter issue

Post by Gagik » 09 Feb 2024, 10:25

I have already done it. Thank you.

Post Reply