Magento stopped generating sitemap suddenly - magento

Sitemap stopped generating suddenly.
Started displaying 'Unable to create XML sitemap.'
Please help

A quick fix to it .
Here I am using fishpig extension .
Observed that fishpig is overridding magento core sitemap controller .
So added the following code : /app/code/community/Fishpig/Wordpress/controllers/Adminhtml/SitemapController.php
Add this code before :
$this->_redirectReferer();
$id = $this->getRequest()->getParam('sitemap_id');
$sitemap = Mage::getModel('sitemap/sitemap');
/* #var $sitemap Mage_Sitemap_Model_Sitemap */
$sitemap->load($id);
// if sitemap record exists
if ($sitemap->getId()) {
try {
$sitemap->generateXml();
$this->_getSession()->addSuccess(
Mage::helper('sitemap')->__('The sitemap "%s" has been generated.', $sitemap->getSitemapFilename()));
}
catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
catch (Exception $e) {
$this->_getSession()->addException($e,
Mage::helper('sitemap')->__('Unable to generate the sitemap.'));
}
} else {
$this->_getSession()->addError(
Mage::helper('sitemap')->__('Unable to find a sitemap to generate.'));
}
Hope it helps someone experiencing with same issue .
Courtesy : lukecollymore

Related

Get websocket data in laravel controller

I have an external WebSocket link where im getting data. My requirement is to receive those data in laravel controller and handle them.
How to listen in controller.
Finally i found the solution.
this has helped me.
$clientWebSoket = new \WebSocket\Client(
'wss://somelink'
);
$clientWebSoket->send(
'{"method":"test","symbols":"some data"}'
);
while ($i) {
try {
$message = $clientWebSoket->receive();
dump($message);
} catch (\WebSocket\ConnectionException $e) {
dd($e);
}
}
$clientWebSoket->close();

Laravel package whoops exception

In my Laravel package I have this code:
try {
$var_msg = "Exception example";
throw new InvalidNameException($var_msg);
}
catch (InvalidNameException $e) {
abort(403, $e->getMessage());
//report($e);Exception Log
}
The error is displayed as html error page. But, I'd like to report the error as an whoops error.
Take this code as reference.
$whoops = new \Whoops\Run();
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
// Set Whoops as the default error and exception handler used by PHP:
$whoops->register();
throw new \RuntimeException("Oopsie!");

magento add to wishlist message in product details page

I want to show Wishlist Success Message in the product details page. I have change the redirection part. Now my page is redirecting to same page after added the product to wishlist. But I need to Show the message in same page. Kindly Help.. Thanks in advance. P.S.- I don't want to use ajax add to wishlist functionality.
The Magento Session models i.e. core/session, customer/session and catalog/session etc.
To add a message you can use "app\code\core\Mage\Wishlist\controllers\IndexController.php":
Action : addAction()
Find :
$session->addSuccess($message);
below write this code:
Mage::getSingleton('catalog/session')->addSuccess($message);
Then add error message :
Find :
catch (Mage_Core_Exception $e) {
$session->addError($this->__('An error occurred while adding item to wishlist: %s', $e->getMessage()));
}
catch (Exception $e) {
$session->addError($this->__('An error occurred while adding item to wishlist.'));
}
replace with below code :
catch (Mage_Core_Exception $e) {
$session->addError($this->__('An error occurred while adding item to wishlist: %s', $e->getMessage()));
$error_msg = $this->__('An error occurred while adding item to wishlist: %s', $e->getMessage());
Mage::getSingleton('catalog/session')->addError($error_msg);
} catch (Exception $e) {
$session->addError($this->__('An error occurred while adding item to wishlist.'));
Mage::getSingleton('catalog/session')->addError('An error occurred while adding item to wishlist.');
}
If "catalog/session" is not working please try "core/session".

magento newsletter keeps returning an error even after email is saved

There was a problem with the subscription.
this is the message I get after I enter an email. When I go to the admin panel the email is added.
I would like it NOT to display this message. any suggestions please
The only place in Magento that error string occurs is in the following try/catch block
#File: app/code/core/Mage/Newsletter/controllers/SubscriberController.php
try {
//...snip!...
}
catch (Mage_Core_Exception $e) {
$session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
}
catch (Exception $e) {
$session->addException($e, $this->__('There was a problem with the subscription.'));
}
Since you reported the error message as "There was a problem with the subscription.", that means the newsletter subscription code is throwing some sore of PHP exception, caught by the catch (Exception $e) { block. Magento does not output the messages from PHP exceptions. If I was in your position I'd temporarily change the exception handling code to include the error message
$session->addException($e, $this->__('There was a problem with the subscription. ' . $e->getMessage()));
This will let you track down the PHP error that's triggering your error message.
Per the comment below, the only place the "Cannot set standard header from addHeader()" exception error exists is
#File: lib/Zend/Mail.php
$prohibit = array('to', 'cc', 'bcc', 'from', 'subject',
'reply-to', 'return-path',
'date', 'message-id',
);
if (in_array(strtolower($name), $prohibit)) {
/**
* #see Zend_Mail_Exception
*/
#require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Cannot set standard header from addHeader()');
}
$value = $this->_filterOther($value);
$value = $this->_encodeHeader($value);
$this->_storeHeader($name, $value, $append);
return $this;
My guess is somewhere in your system someone's added some custom code that tries to set one of the standard email headers via the addHeader method.

Magento issue with email charset

I have a little issue. I'm using to send mail in my custom module this piece of code:
$content = 'Wiadomość testowa ąśźć';
$mail = Mage::getModel('core/email');
$mail->setToName($name);
$mail->setToEmail($email);
$mail->setBody($content);
$mail->setSubject($subject);
$mail->setFromEmail('test#test.com');
$mail->setFromName("Test");
$mail->setType('html');
try {
$mail->send();
Mage::getSingleton('customer/session')->setData('success',Mage::helper('adminhtml')->__('Your request has been sent'));
}
catch (Exception $e) {
Mage::getSingleton('customer/session')->setData('error',Mage::helper('adminhtml')->__('Unable to send email.'));
}
How can I set utf-8 charset before sending email in magento mail function. ?
I get email with no utf-8 charset in email body.
SOLVED
I created sendZendMail function in helper.
I used this function, instead Magento core/email:
public function sendZendMail($name,$email,$subject,$content){
$mail = new Zend_Mail('UTF-8');
$mail->setBodyHtml($content);
$mail->setFrom('your#frommail.com');
$mail->addTo($email, 'No reply');
$mail->setSubject($subject);
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Mail was sucessfully send.');
}
catch(Exception $ex) {
Mage::getSingleton('core/session')->addError('Unable to send email.');
}
}
kristoff, I had the same issue before with Portuguese, which also has special characters. I've sorted it out by using the function htmlentities() for accented words. The Zend Mail Object is a bit retarded. I hope it helps.

Resources