Mini Basket auto reload

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
georg03
Posts: 13
Joined: 15 Jul 2019, 10:46

Mini Basket auto reload

Post by georg03 » 08 Aug 2019, 08:00

Hello,

I read about this topic in some posts but I was not able to get the mini basket running. My problem ist that after I add a product to the basket I need to do a page reload to see the product also in the mini basket. According to the post below the mini basket update happens during the basket overlay is displayed (https://github.com/aimeos/aimeos-core/issues/80). But in my installation nothing happens.

First of all some basic question: Do I need to use the JSON API in order to get this work? Or should it work just with Javasript?

I also read this instructions https://aimeos.org/docs/TYPO3/Add_basket_to_navigation
In the second block you have to assign the jsonapi.url.target. So if this is necessary can you please explain what exactly I have to do?

Thank you!
Last edited by georg03 on 11 Aug 2019, 19:18, edited 1 time in total.

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

Re: Mini Basket auto reload

Post by aimeos » 11 Aug 2019, 09:36

Yes, you need the JSON API for the mini basket and set the page in the Flexforms
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

georg03
Posts: 13
Joined: 15 Jul 2019, 10:46

Re: Mini Basket auto reload

Post by georg03 » 11 Aug 2019, 19:08

Thank you, unfortunately I do not know what exactly I have to do. I placed the JSON REST API plugin on a blank page and set the Confirmation page in the Flexform. Then I set the plugin.tx_aimeos.settings.client.html.basket.standard.url.target & plugin.tx_aimeos.settings.client.jsonapi.url.target in Typoscript setup. Apparatently this is not enough since I still need to reload the mini basket page.

Which settings are missing?

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Mini Basket auto reload

Post by cnoelker » 12 Aug 2019, 11:48

For debugging, it's best to use developer tools of your browser. Go to network and check the requests which are started. Check if the response of JsonApi controller is really JSON.
I noticed that TYPO3 added an a tag with an ID before the JSON was sent as a string. We solved the problem by proving a frame (in appearance) without any additional content.

georg03
Posts: 13
Joined: 15 Jul 2019, 10:46

Re: Mini Basket auto reload

Post by georg03 » 12 Aug 2019, 15:56

Thanks! In developer tools/network I get the following output when I add a product to the basket:

method: Options
file: .../index.php?id=32&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options
source: xhr

I believe I need to set some settings according to https://aimeos.org/docs/Developers/Client/JSONAPI
But I am not sure what is necessary for the mini basket. Also how do I include these settings in Typo3?

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Mini Basket auto reload

Post by cnoelker » 12 Aug 2019, 18:09

I had to set this in TypoScript:
# set the page UID of JSONAPI
plugin.tx_aimeos.settings.client.jsonapi.url.target = 2

If your jsonapi plugin is on your page with ID 32, then this should not be necessary, though.

What is the response of accessing the jsonapi? It should be pure JSON, not a string.

georg03
Posts: 13
Joined: 15 Jul 2019, 10:46

Re: Mini Basket auto reload

Post by georg03 » 12 Aug 2019, 19:04

You mean if I view the page with ID 32? -->

{ "errors": { "title": "Use OPTIONS method for the resource list", "detail": "This is the Aimeos JSON REST API\n\nUse the HTTP OPTIONS method to retrieve a list available resources from http:\/\/WEBSITEURL\/index.php?id=32&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options\nDocumentation about he Aimeos JSON REST API is available at https:\/\/aimeos.org\/docs\/Developers\/Client\/JSONAPI" } }

cnoelker
Advanced
Posts: 140
Joined: 20 Feb 2016, 18:21

Re: Mini Basket auto reload

Post by cnoelker » 12 Aug 2019, 19:06

No, I mean the output of the network request which you can see in the developer tools.

georg03
Posts: 13
Joined: 15 Jul 2019, 10:46

Re: Mini Basket auto reload

Post by georg03 » 12 Aug 2019, 19:42

JSON API REQUEST

http://websiteurl.at/index.php?id=32&ai ... 5D=options / Method: OPTIONS --> Response:

{ "meta": { "prefix": "ai", "content-baseurl": "/uploads/tx_aimeos" , "resources": {"attribute":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=attribute&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","basket":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=basket&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","catalog":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=catalog&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","customer":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=customer&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","locale":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=locale&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","order":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=order&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","product":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=product&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","service":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=service&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","stock":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=stock&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","supplier":"http:\/\/websiteurl.at\/index.php?id=32&ai%5Bresource%5D=supplier&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options"} } }

---

STANDARD BASKET REQUEST

In comparison I also checked the network request from the actual basket standard page with ID 18 / Method: POST
http://websiteurl.at/index.php?id=18&ai ... n%5D=index
here the last added product is not available

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

Re: Mini Basket auto reload

Post by aimeos » 12 Aug 2019, 20:05

The best way of setting the page ID for the "jsonapi" page is if you click on the edit button on each Aimeos plugin on each page, go to the "Plugin" tab and use the page selector for the "JSON API" setting (almost the last of the settings). Using a global setting won't work because TYPO3 then overwrites your global setting with empty values from the plugin configuration.

The TypoScript config for the "jsonapi" page of the default page tree is:

Code: Select all

page = PAGE
page {
    typeNum = 0
    headerData >
    config {
        disableAllHeaderCode = 1
        disableCharsetHeader = 1
        disablePrefixComment = 1
    }
    10 = CONTENT
    10 {
        table = tt_content
        select.orderBy = sorting
        select.languageField = sys_language_uid
    }
}

tt_content.stdWrap >
tt_content.list = COA
tt_content.list.20 = CASE
tt_content.list.20.key.field = list_type
tt_content.list.templateName >
tt_content.list.templateRootPaths >
tt_content.list.partialRootPaths >
tt_content.list.layoutRootPaths >
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply