StorefrontRenderEvent::class event in Shopware 6.2. this event is working only once. then it is not working. I think the event is cached by Shopware.
What I can do?
I want to get the customer id, sales channel context, and need to pass some params to view page. Are there any events available for this without caching?
Shopware uses Full Page Http Cache. You should consider using Ajax for dynamic things
Related
I need to create ShopWare 6 plugin that creates new orders from products that are received via AJAX POST request. I don't know how to do that. I googled and checked documentation but I couldn't find any info on how can it be done.
Does someone know how can it be done?
In my opinion, the best solution would be to create Cart object from products that you get from request probably you know context token so you can use the current customer's cart and add products to it, but also you can create a new cart and then call \Shopware\Core\Checkout\Cart\Order\OrderPersister::persist() method to persist order from your cart.
Take a look here how to load/create a Cart
\Shopware\Core\Checkout\Cart\SalesChannel\CartLoadRoute::load()
Are there any events or hooks available to detect the shop change form frontend (shop change dropdown in the header.)?
How we can check the customer changed the shop in frond-end? (I what to do some function after the shop change in my plugin).
You can detect the change manually by checking the previous url to the current url with PHP.
Here is an entry on how to get the previous URL: How to get the previous url using PHP
You can hook any Shopware Event which is always fired in Shopware. You could use the Event "Enlight_Controller_Action_PostDispatch_Frontend" and extend it.
Greetings Patrick
I'm looking to modify one of my existing portlets which is used concurrently by many users to be able to automatically poll for updates and pull down the latest data in that portlet. That way users don't have to refresh the page to see the new data. In otherwords its automatically checking for new data every 10 seconds and refreshing the data.
Almost like a chat client but its pulling down a JSON object every 10 seconds asynchronously.
No problem. On the browser side, query <portlet:resourceURL/> - this goes to the resource-serving phase of your portlet. From there you can deliver any content type you want (kind of like a servlet)
On the server side, you'll need to query for updated data from all the different users, but that's something independent of the portlet spec and rather considered business logic.
I'm getting BusyConversationException while navigating through pages in my jsf project. This mostly happens if the user tries to navigate to another page during an ajax call. This also happens when the user clicks on a link right after clicking on another link without waiting for loading of the page.
For example if the user clicks on more than one link which are generated through a code similar to below one we definitely get this exception. Another example is, lets say the user enter a query on a text field, and our application make an ajax call for searching this query. During that query if the user click on some button to navigate to another page BusyConversationException occurs too.
<h:commandLink value="#{theProfile.profileName}"
title="#{theProfile.profileName}"
action="#{profileBean.aProfileSelected}">
<f:setPropertyActionListener target="#{currentProfileWebBean.theProfile}" value="#{theProfile}"/>
</h:commandLink>
I can catch this type of exception in an ExceptionHandler class which extends ExceptionHandlerWrapper class but I can't save my current state and the best I can do for this case is to redirect to main page when this exception occurs.
Is there any solution for avoiding this? Thanks in advance for answers and comments.
As mentioned in the other answers, this happens if an ajax request is still being processed or if an ajax event is triggered prior to the actual click on the submitting commandLink or commandButton (for instance by a change event on an input field).
Therfore it is not possible to avoid BusyConversationExceptions with onclick="preventEventPropagation(event)";, since the AJAX events are not triggered via propagation.
The issue can easily be avoided by listening for running ajax requests and blocking submits until the pending ajax events have been completed.
The issue and solution are explained in more detail in this blog post JSF2 AJAX/Submit conversation issue.
i found this,
Indicates that the container has rejected a request because a concurrent request is associated with the same conversation context.
The container ensures that a long-running conversation may be associated with at most one request at a time, by blocking or rejecting concurrent requests. If the container rejects a request, it must associate the request with a new transient conversation and throw an exception of type BusyConversationException from the restore view phase of the JSF lifecycle.
refer here
I've been seeing this occasionally too. I'm starting to think it's a good idea to put some effort into serializing access to conversations:
Avoid propagating the conversation ID (cid) when you don't need that conversation instance for the target view. Specifically, unrelated navigation links/buttons should suppress the cid parameter (haven't thought about exactly how to do that)
When starting a request that uses an active conversation, disable other UI elements that propagate the conversation and could therefore cause concurrent access. The PrimeFaces or (even better) PrimeFaces Extensions blockUI components work well as a translucent overlay, along with a PrimeFaces p:ajaxStatus to show the busy status.
Begin conversations as late as possible. This will minimize the cases where a long-running conversation would be propagated.
I don't think that any of this is a complete solution, though. As soon as the cid ends up in the location bar (which happens when you do a non-ajax post back of a form when a conversation is active), you potentially lose control over the timing of access to that conversation due to multiple tabs/windows, bookmarks, etc.
I also faced the same problem, when I used to click the .
I have read in one of the book, busyConevrsation happens with that event two actions are happening, so they said use : onclick="preventEventPropagation(event)"; in commandLink to prevent the event propagation for that click. So I have used the same and it's working for me.
So now am not getting the BusyConversationException :)
I have a SharePoint site page with a document library web part on it, once a document is uploaded to this library, some of the library fields need to be updated according to a parameter of the page url.
I tried doing this with Event Receiver binding on the library, only to find that I cannot get the page url, or rather the parameter, in the Event Receiver. Then Session occurred to my mind, but after asking around and searching a lot, I can only get HttpContext in itemAdding but not itemAdded, what's worse, HttpContext.Current.Session always give me nulll and I'm sure I have put some value into session earlier in somewhere else.
Can someone shed some light on this, any help or advise is deeply appreciated.
SharePoint allows synchronous and asynchronous event receivers. You can get access to HttpContext and SPContext in synchronous receiver, as it runs in worker thread. Read more for accessing HttpContext and how to bind synchronous receiver programmatically.
It's a bit late but for reference I've just seen solution on this page.
It leverages custom control in master page and stores the information into HttpRuntime.Cache. Then access it from within the synchronous event.
The event receiver is not called in the page context. Therefor you can't access the page information. The only approach to this that I can see is to write custom code that prefills the values of the page before you save the item.