I need to unset the error message session in magento for below code.
Mage::getSingleton('core/session')->addError($message);
Can any one help me?
You should be able to use the following code, though it will return all messages (it will not echo them), it will clear them:
Mage::getSingleton('core/session')->getMessages(true); // The true is for clearing them after loading them
I hope this answers your question. ^_^
Related
I am using this, Saving-User-last-login-Time-in-Grails, simple tutorial to add lastLoginTime to User. So, everytime a user logs in, the last signed in date/time is saved to database. I followed the steps, provided in the tutorial, exactly. But end-up getting this error.
No signature of method: groovy.util.ConfigObject.withTransaction() is
applicable for argument types: (Config$_run_closure3_closure11)
values: [Config$_run_closure3_closure11#12fab25]
Looks like the Gorm code, in Config.groovy file, is not respected. Does anyone know, where else should I move the code to solve this problem?
Any help is much appreciated. Thanks.
Try application.groovy, instead. For details, refer registeringCallbackClosures.
For more insight, and other approaches to achieve similar behaviour, see Events.
I am having a small problem updating my cart because of "undefined index:quantity message coming up on my text box.On the last line of my code. what is wrong with the code? Any kind consideration will be highly appreciated.
function edit_quantity(){
if(isset($_POST['update_cart'])){
$quantity=$_POST['quantity'];
$sql3="UPDATE Shopcart set qty='$quantity'";
$sql3_run=mysqli_query($conn,$sql3);
$_SESSION['quantity']=$quantity;
$total=$total*$quantity;
}
echo $_SESSION['quantity'];
}
i see you dont have session_start();
put it somewhere before you use $_SESSION
edit:
your code might not enter the if block and would not set the quantity session. That's why you are having an Undefied index error move the echo statement inside the if block so that it will echo when your quantity session is set.
This error is because the POST data does not have a quantity value. You are only checking for an update_cart post value before proceeding to update the session.
As others have mentioned, there is also a serious sql injection problem with your code which you should fix.
I'm using Magento's built in Googleanalytics module which is working fine for page views, but not for conversions. The account is set up fine on Google, but it's not adding the addTrans part in the checkout/onepage/success page.
I've done a lot of digging this morning, and found that the observer does observe the "checkout_onepage_controller_success_action" correctly, and does indeed run. It does the following:
$block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics');
if ($block) {
$block->setOrderIds($orderIds);
}
I've done some echoing, and it does retrieve the block, and it also sets the order ids correctly. However, in the block itself, if I echo out $this->getOrderIds(); its empty.
My next thought was that perhaps it could be using two GA blocks on the page, and maybe its passing the data to the first one but echoing the HTML of the 2nd one, but I've no clue how to start checking that! The Googleanalytics.xml file only has one block it in, and I don't use that block name anywhere else!
Anyone experienced similar? Or have any idea where I can go from here?
EDIT:
The Ga.php block includes the transaction code if $this->getOrderIds() returns an array, which it is not doing. However, the observer is doing $block->setOrderIds($order_ids); which is passing through an array containing an order id. So the observer is passing the ids to the block, and the block is receiving them (setting up a method of setBlockIds and echoing out the argument, does show the array), but when the block tries to access its own data, it's suddenly not there ($block->getData() returns an array of properties but there is no order_ids property).
I also figured maybe it could be that its echoing the blocks HTML before setting the order id, so I added some variables in to check that and it's not that - its definitely setting the order_ids before trying to get them again, but its still not working!
I'm completely stumped! My only idea now is to modify the Ga.php block to use Magento's registry instead of it's own _data property, which is really not a nice way of doing it!
I think i've been an utter tool. Magento wasn't tracking conversions on the live site because I hadn't put the account code in the configuration part, but I had on my test site.
I had previously put my own analytics code in the template, so I had tracked page views.
When I saw no conversions (despite putting the account code in my test site), I started making orders on the test site and then viewing the source of the order success page. Firefox loads its source as a new request...which automatically goes to the empty basket page. So obviously, it wasn't showing the addTrans or anything, because it had already done that.
A quick check in firebug revealled it was working as it should.
So in the end, after a day of searching, I had to change "No" to "Yes" in the admin, and type in the account code. Great.
I I've done a lot of looking around for code that'll delete a session variable, and the close I've got to success is with this:
<cfset StructDelete(Session,"username")>
It works the first time, then it never works again. I've spent the past hour on this and am going insane, any help would be much appreciated.
I'm not sure if this is related but when I modify a .cfm for some reason it doesn't always seem to "update" instantly. What I mean is, I'd change a page, access it and it won't use the new code. This is a horror when trying to debug...
I suspect you mean it's coming back into existence and you think it should be gone. Look for any "cfparams" that set the variable. It might be deleted then reinitiated on the next request.
You can also add a boolean to check if it exists when you delete it.
<cfset exists= structdelete(session, 'username', true)/>
This will give you a "yes" if it exists and a "no" if it doesn't - allowing you to execute further logic if you wish.
You might also take a look at your application names, session timeout values onsessionStart() etc. I've seen problems where a new session was being instantiated with each request.
I just cfset the session variable to kill it...
<cfset session.allowin = "False">
And the application.cfm file is always looking for true...
When I turn on cache in Magento, I get the following exception:
Serialization of 'Mage_Core_Model_Layout_Element' is not allowed
Exception occurs in app/code/core/Mage/Page/Block/Template/Links.php, on line:
return parent::getCacheKeyInfo() + array(
'links' => base64_encode(serialize($links)),
'name' => $this->getNameInLayout()
)
I am using Magento Enterprise 1.10 and PHP 5.3.
Can anyone tell me what the problem is?
You shouldn't have an empty after_text or before_text tags in your layout file. If you don't need it, just delete the tag at all.
If it will not help, dump the $links variable before the 150th line in the app/code/core/Mage/Page/Block/Template/Links.php file, and you will see an array with arrays inside it. All of keys and values should be strings or integers, not objects. The key of array value which is an object will tell you which tag to delete from the layout file.
Awesome #vsushkov.
I used:
try{
serialize($links);
} catch(Exception $e){
Mage::log($links);
die;
}
to find out exact layout where we had those empty tags and after removing those empty tags, it fixed the issue and then removed above code :-)
Saw this issue on a clients site. None of the solutions above worked for me. After much googling of the error, it seems to be related to JM or JoomlArt themes/extensions.
The code is extremely poorly written. For example some of the things you will find in these themes include:
Declaring php classes inside templates,
Setting global variables inside templates,
Setting data into superglobals from templates,
Providing a translation file, yet not wrapping most text strings in template in the translate function
I found 1 response from their support staff essentially suggesting to turn off error reporting to fix the issue.
I found my problem in app/design/frontend/default/jm_adamite/template/catalog/navigation/tops.phtml
There was a line setting $this into $_SESSION. I commented it out and the error went away. Nothing else appeared broken. A grep for that variable being used anywhere else had 0 results. If you have one of these JM extensions installed or use one of their themes, I would suspect that first
Good luck
This problem happened to me when trying to serialize categories after calling the getCategoryUrl function after digging i found out that that set _urlModel object which cannot be serialized as it contains Mage_Core_Model_Layout_Element so before serializing the object check if it has that _urlModel property