Magento2 : Use of echo language construct is discouraged
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
I have my RSS feed from controller returned /displayed on frontend using echo , how do I replace echo any alternate method availabale?
MEQP1.Security.LanguageConstruct.DirectOutput
public function execute()
$shopUri = $this->_storeManager->getStore()->getBaseUrl();
$posts = $this->collectionFactory->create()->addFieldToFilter('is_active', 1);
$this->output .= '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA['.$this->myHelper->getFinalIdentifier().']]></title>
<description>Some Title</description>
<link>'.$shopUri.'</link>
<webMaster>'.$this->myHelper->getStoreEmail().'</webMaster>
<image>
<title><![CDATA['.$this->myHelper->getStorename().']]></title>
<link>'.$shopUri.'</link>
</image>';
if (isset($posts) && $posts)
foreach ($posts as $post)
$url = $post->getIdentifier();
$blog_link = $shopUri.$this->myHelper->getDetailIdentifier($url);
$this->output .= '
<item>
<title><![CDATA['.$post->getTitle().']]></title>
<pubDate>'.date('r', strtotime($post->getPublishDate())).'</pubDate>
<description>';
if ($post->getImage())
$this->output .= '<![CDATA[<img src="'.$this->myHelper->resizeImage($post->getImage(), 100, 75).'" title="'.$post->getTitle().'" alt="'.$post->getTitle().'" width="120"/>]]>';
$this->output .= '<![CDATA['.$post->getShortSummary().']]></description>';
$this->output .= '
<link>'.str_replace('&', '&', htmlspecialchars($blog_link)).'</link>
<guid isPermaLink="true">'.str_replace('&', '&', htmlspecialchars($blog_link)).'</guid>
</item>';
$this->output .= '
</channel>
</rss>';
echo $this->output;
xml controllers marketplace rss-feed
add a comment |Â
up vote
3
down vote
favorite
I have my RSS feed from controller returned /displayed on frontend using echo , how do I replace echo any alternate method availabale?
MEQP1.Security.LanguageConstruct.DirectOutput
public function execute()
$shopUri = $this->_storeManager->getStore()->getBaseUrl();
$posts = $this->collectionFactory->create()->addFieldToFilter('is_active', 1);
$this->output .= '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA['.$this->myHelper->getFinalIdentifier().']]></title>
<description>Some Title</description>
<link>'.$shopUri.'</link>
<webMaster>'.$this->myHelper->getStoreEmail().'</webMaster>
<image>
<title><![CDATA['.$this->myHelper->getStorename().']]></title>
<link>'.$shopUri.'</link>
</image>';
if (isset($posts) && $posts)
foreach ($posts as $post)
$url = $post->getIdentifier();
$blog_link = $shopUri.$this->myHelper->getDetailIdentifier($url);
$this->output .= '
<item>
<title><![CDATA['.$post->getTitle().']]></title>
<pubDate>'.date('r', strtotime($post->getPublishDate())).'</pubDate>
<description>';
if ($post->getImage())
$this->output .= '<![CDATA[<img src="'.$this->myHelper->resizeImage($post->getImage(), 100, 75).'" title="'.$post->getTitle().'" alt="'.$post->getTitle().'" width="120"/>]]>';
$this->output .= '<![CDATA['.$post->getShortSummary().']]></description>';
$this->output .= '
<link>'.str_replace('&', '&', htmlspecialchars($blog_link)).'</link>
<guid isPermaLink="true">'.str_replace('&', '&', htmlspecialchars($blog_link)).'</guid>
</item>';
$this->output .= '
</channel>
</rss>';
echo $this->output;
xml controllers marketplace rss-feed
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have my RSS feed from controller returned /displayed on frontend using echo , how do I replace echo any alternate method availabale?
MEQP1.Security.LanguageConstruct.DirectOutput
public function execute()
$shopUri = $this->_storeManager->getStore()->getBaseUrl();
$posts = $this->collectionFactory->create()->addFieldToFilter('is_active', 1);
$this->output .= '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA['.$this->myHelper->getFinalIdentifier().']]></title>
<description>Some Title</description>
<link>'.$shopUri.'</link>
<webMaster>'.$this->myHelper->getStoreEmail().'</webMaster>
<image>
<title><![CDATA['.$this->myHelper->getStorename().']]></title>
<link>'.$shopUri.'</link>
</image>';
if (isset($posts) && $posts)
foreach ($posts as $post)
$url = $post->getIdentifier();
$blog_link = $shopUri.$this->myHelper->getDetailIdentifier($url);
$this->output .= '
<item>
<title><![CDATA['.$post->getTitle().']]></title>
<pubDate>'.date('r', strtotime($post->getPublishDate())).'</pubDate>
<description>';
if ($post->getImage())
$this->output .= '<![CDATA[<img src="'.$this->myHelper->resizeImage($post->getImage(), 100, 75).'" title="'.$post->getTitle().'" alt="'.$post->getTitle().'" width="120"/>]]>';
$this->output .= '<![CDATA['.$post->getShortSummary().']]></description>';
$this->output .= '
<link>'.str_replace('&', '&', htmlspecialchars($blog_link)).'</link>
<guid isPermaLink="true">'.str_replace('&', '&', htmlspecialchars($blog_link)).'</guid>
</item>';
$this->output .= '
</channel>
</rss>';
echo $this->output;
xml controllers marketplace rss-feed
I have my RSS feed from controller returned /displayed on frontend using echo , how do I replace echo any alternate method availabale?
MEQP1.Security.LanguageConstruct.DirectOutput
public function execute()
$shopUri = $this->_storeManager->getStore()->getBaseUrl();
$posts = $this->collectionFactory->create()->addFieldToFilter('is_active', 1);
$this->output .= '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA['.$this->myHelper->getFinalIdentifier().']]></title>
<description>Some Title</description>
<link>'.$shopUri.'</link>
<webMaster>'.$this->myHelper->getStoreEmail().'</webMaster>
<image>
<title><![CDATA['.$this->myHelper->getStorename().']]></title>
<link>'.$shopUri.'</link>
</image>';
if (isset($posts) && $posts)
foreach ($posts as $post)
$url = $post->getIdentifier();
$blog_link = $shopUri.$this->myHelper->getDetailIdentifier($url);
$this->output .= '
<item>
<title><![CDATA['.$post->getTitle().']]></title>
<pubDate>'.date('r', strtotime($post->getPublishDate())).'</pubDate>
<description>';
if ($post->getImage())
$this->output .= '<![CDATA[<img src="'.$this->myHelper->resizeImage($post->getImage(), 100, 75).'" title="'.$post->getTitle().'" alt="'.$post->getTitle().'" width="120"/>]]>';
$this->output .= '<![CDATA['.$post->getShortSummary().']]></description>';
$this->output .= '
<link>'.str_replace('&', '&', htmlspecialchars($blog_link)).'</link>
<guid isPermaLink="true">'.str_replace('&', '&', htmlspecialchars($blog_link)).'</guid>
</item>';
$this->output .= '
</channel>
</rss>';
echo $this->output;
xml controllers marketplace rss-feed
xml controllers marketplace rss-feed
asked 5 hours ago


Verdu
957422
957422
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can use following instead of echo
public function execute()
$data="bdfb";
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$resultJson->setContents($data);
return $resultJson;
Reference
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can use following instead of echo
public function execute()
$data="bdfb";
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$resultJson->setContents($data);
return $resultJson;
Reference
add a comment |Â
up vote
3
down vote
accepted
You can use following instead of echo
public function execute()
$data="bdfb";
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$resultJson->setContents($data);
return $resultJson;
Reference
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can use following instead of echo
public function execute()
$data="bdfb";
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$resultJson->setContents($data);
return $resultJson;
Reference
You can use following instead of echo
public function execute()
$data="bdfb";
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$resultJson->setContents($data);
return $resultJson;
Reference
edited 1 hour ago
answered 3 hours ago


Qaisar Satti
25.4k1154101
25.4k1154101
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245656%2fmagento2-use-of-echo-language-construct-is-discouraged%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password