Price rules

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!
User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Price rules

Post by nvdid » 15 Feb 2024, 18:21

Hi guys

Here's what I did:
1- Define a new price rule (-5%) for category=XXX in: admin/default/jqadm/search/rule
2- Added product Y to the XXX category

Now fetching 'jsonapi/product?id=Y&include=product.price,catalog' results with the subtracted price (-5%) present under the 'included' key in the response:

Code: Select all

{
  "meta": {
  },
  "links": {
  },
  "data": {
    "relationships": {
      "price": {
        "data": [
          {
            "id": "101",
            "type": "price",
            "attributes": {
              "product.lists.id": "425",
              "product.lists.domain": "price",
              "product.lists.refid": "101",
              "product.lists.datestart": null,
              "product.lists.dateend": null,
              "product.lists.config": [],
              "product.lists.position": 0,
              "product.lists.status": 1,
              "product.lists.type": "default"
            }
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "101",
      "type": "price",
      "attributes": {
        "price.id": "101",
        "price.type": "default",
        "price.currencyid": "IRR",
        "price.domain": "product",
        "price.quantity": 1,
        "price.value": "120750.00",
Is it normal that removing 'catalog' from the include (like 'jsonapi/product?id=Y&include=product.price') causes the price rule not to take effect? (No -5% subtracted)

Plus I needed to have dateStart of the price rule which is not present in the response, so I thought maybe it's restricted on the user side.
I tried fetching 'admin/default/jsonadm/product?include=price,catalog' which does not work the same way and the price rule is not effective anyway (the normal price is shown).
I think I'm doing something the wrong way there. How can I have the start/end dates of the price rule?

Thanks so much for any help in advance

Aimeos: 2023.10
PHP: 8.1.2
Env: Linux

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

Re: Price rules

Post by aimeos » 16 Feb 2024, 17:38

nvdid wrote: 15 Feb 2024, 18:21 Is it normal that removing 'catalog' from the include (like 'jsonapi/product?id=Y&include=product.price') causes the price rule not to take effect? (No -5% subtracted)
Yes, because your price rule needs to know if your product is in that category and it doesn't fetch that information from the database itself for performance reasons.
nvdid wrote: 15 Feb 2024, 18:21 Plus I needed to have dateStart of the price rule which is not present in the response, so I thought maybe it's restricted on the user side.
The start/end dates of price rules are internal data only and not communicated to clients at any time. You will never get that dates attached to prices as long as you don't implement an own price rule that adds it's own start/end dates to the price items.
nvdid wrote: 15 Feb 2024, 18:21 I tried fetching 'admin/default/jsonadm/product?include=price,catalog' which does not work the same way and the price rule is not effective anyway (the normal price is shown).
The JSON admin API gives you raw data for managing the items, not the output required by the frontend.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Price rules

Post by nvdid » 16 Feb 2024, 22:39

Thanks so much for the information.
aimeos wrote: 16 Feb 2024, 17:38 The start/end dates of price rules are internal data only and not communicated to clients at any time. You will never get that dates attached to prices as long as you don't implement an own price rule that adds it's own start/end dates to the price items.
Off the topic; is there a way to make ctime (created date time) of a domain (namely CMS) public so that it is shown in the searches of the client side (jsonapi)?

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

Re: Price rules

Post by aimeos » 18 Feb 2024, 12:01

Makes sense to include that information for CMS items. It's now available if you execute:

Code: Select all

composer req aimeos/ai-cms-grapesjs:2023.10.x-dev
See: https://github.com/aimeos/ai-cms-grapes ... d.php#L162
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Price rules

Post by nvdid » 18 Feb 2024, 13:30

It's so great and useful. Thanks you so much

Post Reply