I have a problem with cart update by API.
I use Varnish with Phoenix.
Update cart from website frontend is working fine, but if I try to update cart from API with this code, I get an old cached version of data.
Example: If in XYZ customer's cart I have 3 products and he's adding another from web in Android app mobile which uses the API, then the cart is not updated.
The code that I use for fetching cart details is as below:
$quote = Mage::getModel('sales/quote')->loadByCustomer($customerId);
$cartItems = $quote->getAllVisibleItems();
I think that this problem comes from the use of cookie, but I don't have an idea about how to do it. Obviously, if I disable varnish or if I refresh the cache everything works fine.
I am working on Magento 1.9.0.1, Varnish 3.0.7 and Phoenix 4.2.3
Thanks!
In varnish you will have to clear the cache programmatically for your changes to appear on frontend. You can get the code to clear the cache from the controller action which is called when u clear the cache from backend.
Simply call this action after your API functionality is done and it will work as expected. You can also, Check if varnish clears cache based on any event that is fired. You can trigger this event after your functionality is done.
Also, I think u will have to do it only for the first item that user adds in cart. varnish cache system stops caching based on 5 dis-qualifiers - if user is logged in, if item is in wishlist, if item is added to cart, and 2 more. You can find these dis-qualifiers in its model or helper file. So when first item gets added to cart it should stop caching automatically for rest of the items.
Hope this helps!!
Related
Recently all my Shopify apps have stopped working due to this error. I can still pull data from the api (photos, titles, etc) but I can no longer add items to my cart or check out. this error isn't just happening on my current build but previous builds too. I think I might have made too many requests due to refreshing pages and have been banned from the API temporarily (I've had this happen with another API before). but it's now been 2 days and still no fix.
I'm pretty confident there's nothing wrong with my code because it's happening to other websites that were working before & haven't been touched for a while.
package used: "shopify-buy": "^2.11.0"
Thanks,
Mitchell D
turns out this error occurred because I was in PAUSE AND BUILD mode. so I must be on a plan to add items to the cart using the API? they must have made this change recently
I am setting up a custom widget in Sitefinity 13 that retrieves data from an external source and caches that data on the server-side. I need the widget data to refresh the data on whatever page it is on once that cache timeout is over, but it appears that the Sitefinity page caching mechanism will cache the rendered results of a page and won't make the call to my custom widget's controller to see if we need to update the data. I've looked into the built-in Sitefinity cache dependency functionality, like IHasCacheDependency and SubscribeCacheDependency, but that appears to be geared toward watching when a page, widget, or other item is updated through Sitefinity's mechanisms (e.g. update version of page is published). I don't see a way using that functionality to accomplish my goal.
Am I missing something with the built-in cache dependency module? What options do I have?
You have a few options:
Instead of getting the data from your controller, you can get it via javascript call. That call can be either towards the external source or, if that's not feasible, towards a proxy api controller on your site, which in turn requests the external api. This way the page will be cached, but the JS script will run and will not be dependent on the page cache at all.
Create a new page cache profile in the settings, that has no sliding expiration and lasts exactly the time you need, e.g. 5 minutes. Then set that profile as cache profile of your page. This way page cache will be invalidated exactly when you need it (time-wise).
In Shopify:-
When my for loop code run then this issue occurred:-
"There was a problem loading this website
Try refreshing the page.
If the site still doesn't load, please try again in a few minutes."
console error is
"Failed to load resource: the server responded with a status of 502 ()"
How to fix it.
Seems like your Shopify site has too many collections and products within them so it just fails to load all of them due exceeding memory limits.
I'm assuming that you're trying to replicate the page from the reference URL you provided in your comment. Consider one of the options below to implement the required functionality:
Create different automated collections for each price range using Product price is less than condition. This approach is good as it uses Shopify's engine to generate collections, but it still might be quiet tricky to implement grouping as on the ref site you provided in comments.
Load collections and its products using AJAX requests i.e. request the data only when a customer is scrolling the page down. It will increase page load speed and will slightly decrease the Shopify site load but still is not ideal as data still will be requested on every page load and scrolling down events. You can slightly improve the situation by caching results on the clients' side, but again, is not ideal still.
Create a custom Shopify application that syncs products with your database. Then you can create an URL on your server that will be used as a data provider for your page. It can be requested via AJAX and return JSON with all the products, grouped by collections and matching the request parameters e.g. price less than X.
You can go further and add a proxy extension to your app. Shopify proxy would allow you loading a custom page directly from your server with the data from your database and render it within Shopify site like a part of itself.
In general, this approach gives you more flexibility on data to output, which can also be cached on your side to increase page speed load drastically.
Personally, I would prefer the last option.
I'm using the 'catalogProductAttributeMediaCreate' V2 SOAP service call to create images for products. This worked fine for months but has been failing since a couple of days.
The API call itself returns a successful action. No exception is thrown by Magento and the call returns an image id in the form of a string like '/f/e/ferrari-f12-berlinetta-wallpapers-pictures-backgrounds.jpg_4.jpg'.
But when I check the magento admin backend, no images are shown. When I check the table in mysql I notice that magento hasn't created a record for it. Even though the API call returns a success.
Adding images through the admin backend manually works fine. I've re-installed the entire magento site. But the fauls persists.
When I use the API to remove the image it returns an exception, telling me that the image '/f/e/ferrari-f12-berlinetta-wallpapers-pictures-backgrounds.jpg_4.jpg' does not exist. Which makes sense as it's not present in the database.
So, why does the API returns a successful action and an image ID, when it obviously fails. And where do I start to troubleshoot?
I'm creating a custom module that needs to hook in to the checkout success event in Magento.
What I need to do is this:
1). Once a custom has successfully checked out I need to present a special offer on the success page with a yes/no radio button and submit form. If they select yes I need to add their details to a custom grid in Magento backend that I have already created.
2). I then need to make an API call to a third party CRM using the POST method to authenticate and add the customers details to their billing system.
3). Upon completion there needs to be a way to update the Grid in Magento to change state from "pending..." to "accepted"
I have started the module but I just can't seem to find any clear documentation about making API Calls or POST requests from Magento that I'm beginning to wonder if this is actually possible?
I would be grateful if anyone knows of an extenion or documentation on how to do the above or if they know of a simpler solution...
If neccessary I can submit my module on Github as a reference if someone is able to assist me
Many thanks!
add a custom block to the checkout_onepage_success layout handle via XML. This block will contain your form.
in the controller that processes your form, you can use Zend_Http_Client to make the POST request to the third party API. Alternatively Zend_Rest_Client or Zend_Soap_Client or Zend_XmlRpc_Client if any of these protocols are used. All of those Zend packages are readily available in Magento.
this is just basic loading and updating models, you should already know how to do this