Heyo, been working on a magento theme for a little while now (... and my understanding of the system is slowly but steadily growing). I need to start working on some custom modules soon, and so I'm starting with this little project to get my bearings:
I found a little bit of code to manage a specific task that I have been copying and pasting into template files:
<?php
$ids = $_product->getCategoryIds();
$cat = Mage::getModel('catalog/category')->load($ids[0]);
$isFF = false;
foreach ($ids as $key=>$val) {
$cat = Mage::getModel('catalog/category')->load($val);
$name = $cat->getName();
if ( $name === 'Fast Fulfillment' ) {
$isFF = true;
}
}
if ($isFF) { echo '<span class="ff-logo"></span>'; }
?>
Very simple. I'm just checking to see if a product is in a specific category, and producing an element if it is. (I know there are about 5 solid ways of doing this... this is the one I went with).
I need to test this every time a product block is displayed, and have, up till now, been replicating this code to make it work. It does work, but is backasswards (I shouldn't be putting logic into the view layer).
Ok - so, lets make a simple module to share the functionality:
local/WACI/ProductFlag/etc/config.xml
<config>
<modules>
<WACI_ProductFlag>
<version>0.1.0</version>
</WACI_ProductFlag>
</modules>
<global>
<blocks>
<WACI_ProductFlag>
<class>WACI_ProductFlag_Block_View</class>
</WACI_ProductFlag>
</blocks>
</global>
</config>
etc/modules/WACI_All.xml
<config>
<modules>
<WACI_CustomPageLayouts>
<codePool>local</codePool>
<active>true</active>
</WACI_CustomPageLayouts>
</modules>
<modules>
<WACI_ProductFlag>
<codePool>local</codePool>
<active>true</active>
</WACI_ProductFlag>
</modules>
</config>
Now, for the Class ... I'm not really sure if a Block or a Helper is appropriate. I went with Block, but - idk... I'm probably wrong (tutorials for this stuff vary wildly).
local/WACI/ProductFlag/Block/View.php
<?php
/**
* WACI
*
* #codepool Local
* #category View
* #package WACI
* #module ProductFlag
*/
class WACI_ProductFlag_Block_View extends Mage_Core_Block_Template
{
private $_focus;
private $_isFF = false;
public function getIsFF( $product ){
$this->_focus = "FF";
$isFF = false;
$ids = $product->getCategoryIds();
$cat = Mage::getModel('catalog/category')->load($ids[0]);
foreach ($ids as $key=>$val) {
$cat = Mage::getModel('catalog/category')->load($val);
$name = $cat->getName();
if ( $name === 'Fast Fulfillment' ) {
$isFF = true;
}
}
}
protected function _toHtml(){
$html = parent::_toHtml();
if ($this->_focus === "FF") {
if ($this->_isFF){
$html .= '<span class="ff-logo"></span>';
}
}
return $html;
}
}
?>
Hopefully its clear that I only want to output a string based on the input of any given product. Should I be overriding the _toHtml() to deliver the string? Again. Probably not...
in my local.xml I reference the block:
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block type="WACI/ProductFlag" name="product.flag" as="productFlag" output="toHtml" />...
... I'm not clear if this instantiates this class? I don't think so. I'm not really sure how to address it in my product/view/media.phtml anyway, given that I need to call a method with a parameter.
I don't think I need a template file, given that I'm just outputting a string, but I don't think I've seen block modules without an associated template. Maybe a helper class is appropriate then?
Whatever the case, it ain't workin.
I either get a fatal error saying my media class has no getIsFF() method (not surprising), or just nothing shows up. My config files are correct, but that's about it, I think.
Jebus. I'm all turned around.
Can someone with Mage skillz clarify this simple issue and point me in the right direction?
Cheers!
No advice? Well = I sussed out this slightly modified and working solution:
local/WACI/ProductFlag/etc/config.xml
<config>
<modules>
<WACI_ProductFlag>
<version>0.1.0</version>
</WACI_ProductFlag>
</modules>
<global>
<blocks>
<productflag>
<class>WACI_ProductFlag_Block</class>
</productflag>
</blocks>
<helpers>
<productflag>
<class>WACI_ProductFlag_Helper</class>
</productflag>
</helpers>
</global>
</config>
local/WACI/ProductFlag/Helper/Flag.php
class WACI_ProductFlag_Helper_Flag extends Mage_Core_Helper_Abstract
{
private $_isFF = false;
public function getIsFF( $product ){
$html = '';
$ids = $product->getCategoryIds();
$cat = Mage::getModel('catalog/category')->load($ids[0]);
foreach ($ids as $key=>$val) {
$cat = Mage::getModel('catalog/category')->load($val);
$name = $cat->getName();
if ( $name === 'Fast Fulfillment' ) {
$this->_isFF = true;
}
}
if($this->_isFF) {
$html = '<span class="ff-logo"></span>';
}
return $html;
}
}
and call it up in any template file via the simple:
<?php echo $this->helper('productflag/flag')->getIsFF($_product); ?>
I'm still not sure if this is exactly appropriate to the magento way of doing things - ie the model calls, I think, should be relegated to their own class and dropped in a Model folder.
Whatever the case - and for anyone else trying to figure this stuff out - as I monkeyed around with it I slowly realized the intent of the config.xml file is to add available factory classes to the blocks/helpers/model pools - and that the path is to the containing directory. The helper call in the template file, then, identifies the "short name" of the directory and then the actual class name.
ie - You could have multiple classes of helpers:
<?php echo $this->helper('productflag/class_one')->someMethod($_product); ?>
<?php echo $this->helper('productflag/class_two')->someOtherMethod($_product); ?>
<?php echo $this->helper('productflag/class_three')->yetAnotherMethod($_product); ?>
So... One step closer.
Related
I am overriding the Mage_Core_Model_Encryption in my module to override hash, getHash, and validateHash methods.
Since urls in the admin side of things use hashing as well, I am overriding the Mage_Adminhtml_Model_Url getSecretKey method so that it will use (faster) md5 hashing in the urls.
The problem I have noticed is that when I clear my cache (config only is enabled) and load the admin/index my encyptor is not registered. It takes until the third request for it to be seen.
I have debugging statements in Mycompany_Encryption_Adminhtml_Url which show that it is immediately loaded with the module. After clearing my cache, I can see my debug statements are working.
When I use the following statement:
var_dump('Class name: '.get_class(Mage::helper('core')->getEncryptor() ) );
I see returned to admin/index (upon refreshing the page) that the class name is Mage_Core_Model_Encryption, then on the third refresh it shows me my class, Mycompany_Encryption_Model_Encryption.
Why does this take three requests? I have been searching all over and haven't found/figured out the problem yet. By all appearances, I have this configured correctly ( and have experimented with a bunch of alternatives).
Can anyone help me solve this issue?
(Below are config, Url class, and Encryption class snippets). Big thanks in advance for any help.
Update, am using modman, here is my modman too:
# Modman file allows Modman to generate links in Magento.
code app/code/local/Mycompany/Encryption/
Mycompany_Encryption.xml app/etc/modules/Mycompany_Encryption.xml
Here is my config:
<config>
<modules>
<Mycompany_Encryption>
<version>0.1</version>
<depends>
<Mage_Core />
</depends>
</Mycompany_Encryption>
</modules>
<phpunit>
<suite>
<modules>
<Mycompany_Encryption />
</modules>
</suite>
</phpunit>
<global>
<helpers>
<core>
<encryption_model>
<class>Mycompany_Encryption_Model_Encryption</class>
</encryption_model>
</core>
</helpers>
<models>
<mycompany_encryption>
<class>Mycompany_Encryption_Model</class>
</mycompany_encryption>
<core>
<rewrite>
<encryption>Mycompany_Encryption_Model_Encryption</encryption>
</rewrite>
</core>
<adminhtml>
<rewrite>
<url>Mycompany_Encryption_Model_Adminhtml_Url</url>
</rewrite>
</adminhtml>
</models>
</global>
</config>
Url class:
class Mycompany_Encryption_Model_Adminhtml_Url extends Mage_Adminhtml_Model_Url
{
/**
* Generate secret key for controller and action based on form key
*
* #param string $controller Controller name
* #param string $action Action name
* #return string
*/
public function getSecretKey($controller = null, $action = null)
{
$salt = Mage::getSingleton('core/session')->getFormKey();
$p = explode('/', trim($this->getRequest()->getOriginalPathInfo(), '/'));
if (!$controller) {
var_dump('Not Controller');
$controller = !empty($p[1]) ? $p[1] : $this->getRequest()->getControllerName();
}
if (!$action) {
var_dump('Not Action');
$action = !empty($p[2]) ? $p[2] : $this->getRequest()->getActionName();
}
$secret = $controller . $action . $salt;
// Here are my debug statements showing when class/method become available.
var_dump('Method exists: '.method_exists(Mage::helper('core')->getEncryptor(), 'urlHash'));
var_dump('Class name: '.get_class(Mage::helper('core')->getEncryptor() ) );
/* This is what I want to return - but sends error 500 until instantiated. */
//return Mage::helper('core')->getEncryptor()->urlHash($secret);
return false;
}
}
Encryption class:
class Mycompany_Encryption_Model_Encryption extends Mage_Core_Model_Encryption
{
public function hash($data)
{
return password_hash($data, PASSWORD_BCRYPT);
}
public function validateHash($password, $hash)
{
return password_verify($password, $hash);
}
public function getHash($value)
{
return $this->hash($value);
}
public function urlHash($value)
{
return md5($value);
}
}
Using the n98-magerun tool, I was able to config:dump and search for the global/helpers/core node.
With the above configuration, I was getting this badly formed config dump:
$ n98-magerun config:dump |cat |grep -A1 -B2 encryption_model
<helpers>
<core>
<encryption_model>Mage_Core_Model_Encryption<class>Mycompany_Encryption_Model_Encryption</class></encryption_model>
</core>
It appears to clear up if I remove the <class> tags in my config.xml:
<helpers>
...
<core>
<!-- Class tags were surrounding my encryption_model value before -->
<encryption_model>Mycompany_Encryption_Model_Encryption</encryption_model>
</core>
...
</helpers>
With this change, I clear cache and get a better config dump:
$ n98-magerun cache:clean config
config cache cleaned
$ n98-magerun config:dump |cat |grep -A1 -B2 encryption_model
<helpers>
<core>
<encryption_model>Mycompany_Encryption_Model_Encryption</encryption_model>
</core>
Please comment with a doc link or provide info if you know why this was happening! Thanks!
For Magento 1.9 I'm working on a module where I defined a custom REST route to retrieve all categories with subcategories. When I call <MAGE>/api/rest/eoarestapi/categories?type=rest the function _retrieveCollection() from the class Namespace_Restapi_Model_Api2_Category_Rest_Guest_V1 is being called. So far so good.
Now I am having the problem, that it returns the response in XML only and when I set the header explicitly to Accept: application/json, then I get the error 406 Not Acceptable An appropriate representation of the requested resource /api/rest/products could not be found on this server. Available variants: api.php , type application/x-httpd-php
This seems very strange to me as I can remember having worked with JSON response back in Magento 1.8.
As a fix I found this and that solution to retrieve JSON which works, but it doesn't seem to be a nice solution as it looks like it disables XML response completely.
Is there a better way to enable JSON output from the REST API in Magento 1.9?
Does anybody have some background knowledge on this?
First I defined #return mixed in my API interface
and than in your model I do this
$response = ['success' => 'ok', 'message' => 'json format'];
header('Content-Type: application/json');
echo json_encode($response); exit;
I achieved this by overriding my request model. My Steps are following:
1:Declare new module : Create app/etc/modules/Custom_RestJson.xml
<?xml version="1.0"?>
<config>
<modules>
<Custom_RestJson>
<active>true</active>
<codePool>local</codePool>
</Custom_RestJson>
</modules>
</config>
2. Create /app/code/local/Custom/RestJson/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Custom_RestJson>
<version>1.0.0</version>
</Custom_RestJson>
</modules>
<global>
<models>
<Custom_RestJson>
<class>Custom_RestJson_Model</class>
</Custom_RestJson>
<api2>
<rewrite>
<request>Core_Mage_Api2_Model_Request</request>
</rewrite>
</api2>
</models>
</global>
</config>
3. Create /app/code/local/Custom/RestJson/Model/Api2/Request.php
<?php
class Custom_RestJson_Model_Api2_Request extends Mage_Api2_Model_Request{
public function getAcceptTypes()
{
$qualityToTypes = array();
$orderedTypes = array();
foreach (preg_split('/,\s*/', $this->getHeader('Accept')) as $definition) {
$typeWithQ = explode(';', $definition);
$mimeType = trim(array_shift($typeWithQ));
// check MIME type validity
if (!preg_match('~^([0-9a-z*+\-]+)(?:/([0-9a-z*+\-\.]+))?$~i', $mimeType)) {
continue;
}
$quality = '1.0'; // default value for quality
if ($typeWithQ) {
$qAndValue = explode('=', $typeWithQ[0]);
if (2 == count($qAndValue)) {
$quality = $qAndValue[1];
}
}
$qualityToTypes[$quality][$mimeType] = true;
}
krsort($qualityToTypes);
foreach ($qualityToTypes as $typeList) {
$orderedTypes += $typeList;
}
return array_keys(array("application/json" => 1));
}
}
I'm pretty new to Magento, and having problems trying to set a custom shipping method programmatically. I'm converting an xml from a thrid party into an order, and everything else (that I've worked on so far) is working fine. Also I'm having problems spelling "programmatically" but I won't ask for you help with that.
I set up my custom shipping method as follows:
To activate the shipping module in
app/etc/modules/Extension_Shipping.xml
<?xml version=
"1.0"?>
<config>
<modules>
<Extension_Shipping>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Shipping/>
</depends>
</Extension_Shipping>
</modules>
</config>
then to configure it in
app/code/local/Extension/Shipping/etc/config.xml
<?xml version=
"1.0" ?>
<config>
<modules>
<Extension_Shipping>
<version>0.1.0</version>
</Extension_Shipping>
</modules>
<global>
<models>
<extension_shipping>
<class>Extension_Shipping_Model</class>
</extension_shipping>
</models>
</global>
<default>
<carriers>
<extension_myrate>
<active>1</active>
<model>extension_shipping/carrier_myrate</model>
<title>Extension Shipping</title>
<name>Default Rate</name>
</extension_myrate>
</carriers>
</default>
</config>
then to add the class in
app/code/local/Extension/Shipping/Model/Carrier/MyRate.php
<?php
class Extension_Shipping_Model_Carrier_MyRate
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
{
protected $_code = 'extension_myrate';
protected $_isFixed = true;
public function collectRates(Mage_Shipping_Model_Rate_Request
$request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('extension_myrate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('extension_myrate');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice(5);
$method->setCost(2);
$result->append($method);
return $result;
}
public function getAllowedMethods()
{
return array('extension_myrate' => $this->getConfigData('name'));
}
}
Basically I followed http://www.magentotricks.com/creating-a-customer-magento-shipping-method/
I thought it all worked fine, as the shipping method now shows up in the checkout screen, and can be set both by customers or in the admin "create new order." However, I'm not able to set it programmatically.
In my controller I'm trying to set the shipping method using the code
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()
->setShippingMethod('extension_myrate')
->setPaymentMethod('checkmo');
To add to my confusion, it worked once. but only once out of quite a few test orders. changing the "setShippingMethod" to "freeshipping_freeshipping" or "flatrate_flatrate" makes it update the shipping to those correctly. because of that and because I'm new and still having problems with the file structure, I'm guessing my problem is with setShippingMethod('extension_myrate') but I'm not entirely sure. Any advice would be helpful and appreciated.
First off, I must apologize for my lack of knowledge on the subject. I'm still new to Magento, and with the information I've come across, I should've been able to get this working. I started off here. I'm able to get the Ajax method to make a call, but I'm getting a blank 2column-left.phtml as my output (So I'm seeing the header, left column, blank main column, and footer). I have my files set up as so:
app/local/MyModule/Featured/Block/Featured.php
<?php
class MyModule_Featured_Block_Featured extends Mage_Core_Block_Template
{
public function __construct()
{
$this->_controller = 'featured';
$this->_blockGroup = 'featured';
parent::__construct();
}
}
?>
app/local/MyModule/Featured/controllers/FeaturedController.php
<?php
class MyModule_Featured_FeaturedController extends Mage_Core_Controller_Front_Action
{
public function displayAction()
{
$this->loadLayout()->renderLayout();
}
}
?>
app/local/MyModule/Featured/etc/config.xml
<config>
<modules>
<MyModule_Featured>
<version>0.1.0</version>
</MyModule_Featured>
</modules>
<frontend>
<routers>
<featured>
<use>standard</use>
<args>
<module>MyModule_Featured</module>
<frontName>featured</frontName>
</args>
</featured>
</routers>
</frontend>
</config>
app/design/frontend/default/myLayout/layout/local.xml
<config>
<featured_featured_display>
<block type="module/block" name="root" output="toHtml" template="catalog/product/featured.phtml" />
</featured_featured_display>
</config>
Ajax Code on Homepage custom phtml:
var url = "<?php echo $this->getUrl('featured/featured/display') ;?>";
jQuery(document).ready(function() {
jQuery('#featured-products').load(url);
});
I believe the layout file's root node should be <layout> and not <config>.
P.S.
If you wanted to do without jQuery - to avoid bloat - Magento already has Prototype as standard and can do exactly the same.
var url = "<?php echo $this->getUrl('featured/featured/display') ?>";
document.observer('dom:loaded', function(){
new Ajax.Updater('featured-products', url);
});
Load layout includes the default handle normally, so my guess is that your assignment has no effect because there is a root note being loaded already. Try removing the root node first, and then add it back as your only node.
I'm trying to write an observer that will export order data when an order is placed. I haven't written any modules before. Basing my implementation on this article: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
so far I'm just trying to trigger some dummy code to write to a file. I'm not getting anything showing in my log, and the file's not being modified. The apache user has permission for the directory. I've disabled configuration caching in the Magento settings. I'm a little confused on some of the naming conventions; I just tried to follow the example. Anyone know where I'm going wrong?
in magento/app/etc/modules/Feed.xml:
<?xml version="1.0"?>
<config>
<modules>
<Feed_Sales>
<codePool>local</codePool>
<active>true</active>
</Feed_Sales>
</modules>
</config>
in magento/app/code/local/Feed/Sales/etc/config.xml:
<?xml version="1.0"?>
<config>
<global>
<models>
<feedsales>
<class>Feed_Sales_Model</class>
</feedsales>
</models>
<events>
<sales_order_place_after>
<observers>
<feed_sales_order_observer>
<type>singleton</type>
<class>sales/order_observer</class><!-- I've also tried Feed_Sales_Model_Order_Observer here -->
<method>export_new_order</method>
</feed_sales_order_observer>
</observers>
</sales_order_place_after>
</events>
</global>
</config>
in magento/app/code/local/Feed/Sales/Model/Order/Observer.php:
<?php
class Feed_Sales_Model_Order_Observer
{
public function __contruct()
{
}
/**
* Exports new orders to an xml file
* #param Varien_Event_Observer $observer
* #return Feed_Sales_Model_Order_Observer
*/
public function export_new_order($observer)
{
Mage::log("reached export_new_order");
try
{
$dumpFile = fopen('/home/jorelli/new_orders/testdump', 'w+');
fwrite($dumpFile, 'this is a test!');
}
catch (Exception $e)
{
Mage::log("order export failed.\n");
}
return $this;
}
}
?>
Magento 1.4 on Debian Lenny with Apache2 if it should matter for any reason.
Read my articles, they'll help you understand what's going on from a naming convention standpoint and get you grounded in some of Magento's conventions/assumptions.
Looking at the samples above, you have a few things not quite right.
First, your file in the etc folder is named wrong
magento/app/etc/modules/Feed.xml
This file needs to be named Packagename_Modulename, so you probably want
magento/app/etc/modules/Feed_Sales.xml
Look at System -> Configuration -> Advanced to see if your module shows up. If it does, you'll have named this file correctly. Without this, the module you created isn't being loaded into the system, and your code never has a chance to run.
Next, you're specifying the class incorrectly. You say
sales/order_observer
but that first part of the URI (sales) is incorrect. You defined your models section as
<models>
<feedsales> <!-- this is your model part -->
<class>Feed_Sales_Model</class>
</feedsales>
</models>
which means you want
feedsales/order_observer
Checkout the Class/URI tab of Commerce Bug and try entering some URIs (like sales/order) to get a better idea of what's going on here.
Another quick tip, when you're trying to get your handler setup, do it for an event that fires on every page load. Then, once you have your method being called, you can switch it to the specific event you want and not have to go through the entire purchase process.
Finally, and I realize you were copying examples, consider putting your module in a folder named something other than Sales. I find mimicking the names of Magento core folders only add an extra layer of confusion, which is not what you need while you're learning the system.
The problem seems to be with your observer declaration. Give this a try:
<events>
<sales_order_place_after>
<observers>
<feed_sales_order_observer>
<type>singleton</type>
<class>feedsales/order_observer</class>
<method>export_new_order</method>
</feed_sales_order_observer>
</observers>
</sales_order_place_after>
</events>
Holy crap. I was stupid. I tested it out with a command line script, like I do with a lot of things, but that particular file was only writeable by the command line interpreter, not the Apache interpreter. I should have left the office earlier last night.
Well for the record, this is how you trigger an action on order placement. I'll leave it up for posterity.
better use this event instead of sales_order_save_after and checkout_onepage_controller_success_action
checkout_submit_all_after
it will work even site not redirected to success page because of some errors like internet issue and all.
try to use below code my requirement also same
namespace Custom\Checkout\Observer;
use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Simplexml\Element as SimpleXMLElement;
class Afterplaceorder implements ObserverInterface
{
protected $_request;
protected $_layout;
protected $_dir;
protected $jsonHelper;
protected $timezone;
protected $_io;
protected $_RandomBytes;
public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Framework\Filesystem\DirectoryList $dir,
\Magento\Framework\Json\Helper\Data $jsonHelper,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
\Magento\Framework\Filesystem\Io\File $io,
\Magento\Framework\Math\Random $RandomBytes
){
$this->_layout = $context->getLayout();
$this->_request = $context->getRequest();
$this->_dir = $dir;
$this->jsonHelper = $jsonHelper;
$this->timezone = $timezone;
$this->_io = $io;
$this->_RandomBytes = $RandomBytes;
}
/**
* #param \Magento\Framework\Event\Observer $observer
* #return void
*/
public function execute(EventObserver $observer)
{
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/orderdata.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$order = $observer->getData('order');
$quote = $observer->getQuote();
try{
// function defination to convert array to xml
function array_to_xml( $data, &$xml_data ) {
foreach( $data as $key => $value ) {
if( is_numeric($key) ){
$key = 'item'.$key; //dealing with <0/>..<n/> issues
}
if( is_array($value) ) {
$subnode = $xml_data->addChild($key);
array_to_xml($value, $subnode);
} else {
$xml_data->addChild("$key",htmlspecialchars("$value"));
}
}
}
$data = array('total_stud' => 500);
// creating object of SimpleXMLElement
$xml_data = new SimpleXMLElement('<?xml version="1.0"?><order></order>');
// function call to convert array to xml
array_to_xml($orderDeatails,$xml_data);
//saving generated xml file;
if ( ! file_exists($this->_dir->getPath('var').'/api/order')) {
$this->_io->mkdir($this->_dir->getPath('var').'/api/order', 0775);
}
$result = $xml_data->asXML($this->_dir->getRoot().'/var/api/order/order_'.$order->getIncrementId().'.xml');
}catch(\Exception $e){
$logger->info(print_r('error-> '.$e->getMessage(),true));
}
}
}
hope it will help you!
Happy Coding!!