Page 1 of 2

Mini Basket auto reload

Posted: 08 Aug 2019, 08:00
by georg03
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!

Re: Mini Basket auto reload

Posted: 11 Aug 2019, 09:36
by aimeos
Yes, you need the JSON API for the mini basket and set the page in the Flexforms

Re: Mini Basket auto reload

Posted: 11 Aug 2019, 19:08
by georg03
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?

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 11:48
by cnoelker
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.

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 15:56
by georg03
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?

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 18:09
by cnoelker
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.

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 19:04
by georg03
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" } }

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 19:06
by cnoelker
No, I mean the output of the network request which you can see in the developer tools.

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 19:42
by georg03
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

Re: Mini Basket auto reload

Posted: 12 Aug 2019, 20:05
by aimeos
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 >