tag:blogger.com,1999:blog-52040602395094404302024-03-13T03:03:58.162-07:00Magento HelperHelping people to get out of the Mage Cage.dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-5204060239509440430.post-16678036758876888942019-03-24T03:05:00.001-07:002019-03-24T03:09:12.308-07:00Magento 2 - Admin Menu Search<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
Today am very happy to announce that my Extension is accepted by <a href="https://marketplace.magento.com/" target="_blank">Magento Marketplace.</a></div>
<div>
I got this Idea about a year ago, I started developing it. But due to my busy office and personal work I was no able to complete it. </div>
<div>
<br /></div>
<div>
In the mean time I thought somebody would definitely create it and submit something similar, but luckly no one did. 😊 So then I thought I should definitely complete and submit it for Magento community. After spending some time fixing all the bugs and proper review, I submitted for Magento's approval.</div>
<div>
<br /></div>
<div>
It took over a month for Manual QA and Marketing team's review. QA just found one bug which I fixed it quickly and resubmitted. </div>
<div>
<br /></div>
<div>
OK, that's the story of it. Here's the <a href="https://marketplace.magento.com/magehelper-menusearch.html" target="_blank">link</a> for my simple extension for Magento 2.</div>
<div>
<br /></div>
<div>
<u>A quick brief about the extension,</u> Admin Menu Search. This will help you to search through all the available Links in Admin panel(Backend) Menu(Navigation). I hope this will be extremely helpful for newbies developers, website administrators, content writers, Marketing teams to quickly go through the options available for this in one place.</div>
<div>
<br /></div>
<div>
Detailed description with screenshots is provided on the <a href="https://marketplace.magento.com/magehelper-menusearch.html" target="_blank">extension page</a>. Please check out to see its complete list of features.</div>
<div>
<br /></div>
<div>
Please install and try the extension. Comment if it is useful and if you find any bugs.</div>
</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-52626719847757838162018-03-26T06:19:00.003-07:002018-03-26T09:42:19.767-07:00Add Custom JS on Magento 2 admin<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
I was creating a new extension that involves customization on Magento 2 Admin panel. As part of it, I needed to add custom javascript on the admin panel.<br />
<br />
There are two ways you can add your custom JS on admin panel.<br />
<br />
<ul style="text-align: left;">
<li>Including it with blocks</li>
<li>Including it in head and loading by require js</li>
</ul>
<div>
<br /></div>
<div>
<b><u>Including it with Blocks</u></b></div>
<div>
<br /></div>
<div>
create folder structure like this <b><span style="font-family: "courier new" , "courier" , monospace;">view/adminhtml/layout/</span></b></div>
<div>
create new file <b><span style="font-family: "courier new" , "courier" , monospace;">default.xml</span></b> inside it.<br />
<br />
<pre class="brush:php;"><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referencecontainer name="js">
<block class="Magento\Backend\Block\Template" name="admincustomjs" template="Your_Modulename::system/config/additional_script.phtml">
</block></referencecontainer>
</body>
</page>
</pre>
<br />
If you want to include your script in footer just replace the referencecontainer name="footer"<br />
<br />
In<b> <span style="font-family: "courier new" , "courier" , monospace;">additional_script.phtml</span></b><span style="font-family: "courier new" , "courier" , monospace;"> </span>you can include your custom script like this.<br />
<pre class="brush:php;"><script type="text/javascript">
require(
['jquery'],
function($) {
$(function() {
console.log('custom script included successfully');
});
});
</script>
</pre>
If you see page source of the system config page or any other page in admin panel, you can see there are few custom scripts included by Magento Just above the Footer tag.<br />
<br /></div>
<div style="text-align: left;">
<b><u>Including it in head and loading by require js</u></b></div>
<div style="text-align: left;">
<b><u><br /></u></b></div>
<div style="text-align: left;">
When using this method don't use default.xml to include your script in <head> tag. This will load your script BEFORE the main require js is loaded and it will create a JS error.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
create folder structure like this <b><span style="font-family: "courier new" , "courier" , monospace;">view/adminhtml/layout/adminhtml_system_config_edit.xml</span></b></div>
<div style="text-align: left;">
<b><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></b></div>
<div style="text-align: left;">
You can change the xml file name inside layout folder as per your admin page action. <span style="font-family: "courier new" , "courier" , monospace;">EG: customer_index_edit.xml</span></div>
<div style="text-align: left;">
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: left;">
<div>
<span style="font-family: inherit;">
</span>
<br />
<pre class="brush:php;"><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Your_Modulename::js/custom_require.js"/>
</head>
<body/>
</page>
</pre>
</div>
</div>
</div>
<div>
You need to place the <b><span style="font-family: "courier new" , "courier" , monospace;">custom</span></b>_require<b><span style="font-family: "courier new" , "courier" , monospace;">.js</span></b> inside <b><span style="font-family: "courier new" , "courier" , monospace;">view/adminhtml/web/js/ </span></b></div>
<div>
In custom_require.js use require method to include your custom javascript.</div>
<div>
<br /></div>
<pre class="brush:php;">require([
'Your_Modulename/custom_system_config'
]);
</pre>
<div>
Create<b><span style="font-family: "courier new" , "courier" , monospace;"> custom_system_config.js</span></b> file inside <b><span style="font-family: "courier new" , "courier" , monospace;">view/adminhtml/web/</span></b></div>
<div>
place your custom javascript in this file</div>
<div>
<br /></div>
<pre class="brush:php;">define([
"jquery"
],&nbsp
function($) {
"use strict";
$(document).ready(function($){
console.log("custom script included successfully");
});
return;
});
</pre>
<div>
If you want to include any <b>third party min JS files</b> you can place it here and you can call its API. </div>
<div>
Using this method, your custom javascript file will be called using <b>require js</b>.</div>
<div>
<br /></div>
<div>
You can see Magento 2 core modules uses both the methods. </div>
<div>
<br /></div>
<div>
For First method, you can refer <b><span style="font-family: "courier new" , "courier" , monospace;">vendor\magento\module-paypal\view\adminhtml\layout\adminhtml_system_config_edit.xml</span></b></div>
<div>
<b><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></b></div>
<div>
For Second method, you can refer <b><span style="font-family: "courier new" , "courier" , monospace;">vendor\magento\module-customer\view\adminhtml\layout\customer_index_edit.xml</span></b></div>
</div>
</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-9533366054995303102017-04-02T22:57:00.001-07:002017-04-02T22:58:06.578-07:00Custom logger in magento 2 | FirePhp | Console log<div dir="ltr" style="text-align: left;" trbidi="on">
In my <a href="http://magehelper.blogspot.com/2015/05/logging-in-magento-2-including-firephp.html" target="_blank">previous post</a> I have explained how to use logger in Magento 2. This post details using FirePHP logging in Magento 2.<br />
<br />
This awesome logging will output the Log data on your Browser console. I have tested on <b>Chrome & Firefox. </b>In this post I will be referencing Chrome.<br />
<b><br /></b>
<b><u>Step 1:</u></b><br />
Install Extension for Chrome.<br />
You need to install two extensions, <a href="https://chrome.google.com/webstore/detail/firephp4chrome/gpgbmonepdpnacijbbdijfbecmgoojma" target="_blank">one</a> is regular logging and <a href="https://chrome.google.com/webstore/detail/firephp-chrome/aleccmdjeoaihoekgpohjfombpekdghf" target="_blank">Other</a> is for logging during Ajax requests.<br />
<br />
<b><u>Step 2:</u></b><br />
Now we need to add our codes to ignore the regular logging to files and output the logs on our browser console.<br />
Creating Logger instance using DI is explained in <a href="http://magehelper.blogspot.com/2015/05/logging-in-magento-2-including-firephp.html" target="_blank">previous post</a>. Please go though if you haven't yet.<br />
Magento 2 includes FirePHP by default. We just need to call it for logging.<br />
<br />
After creating the $this->_logger Object. use below code.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->pushHandler(new \Monolog\Handler\FirePHPHandler());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addDebug('Debug log');</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
There are multiple types for logging.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addInfo();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addNotice();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addError();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addWarning();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger-></span><span style="font-family: "courier new" , "courier" , monospace;">addEmergency();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger-></span><span style="font-family: "courier new" , "courier" , monospace;">addCritical();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger-></span><span style="font-family: "courier new" , "courier" , monospace;">addAlert();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;"><u style="font-weight: bold;">NOTE:</u> If you want to log an <b>array(), </b>you need to pass it as a second argument which is optional.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addDebug('Debug array', $arrayVar);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;"><b><u>Example output</u></b></span><br />
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir8XuCwQw3NoGKZZs-UD3U6tT1B6peug0H-tYaf5kyvOIv83c_ZEqQwGV9D91wyh4QLoQRa2smj9tLuL4H_R_z1Mmz_BJlnJ0le7eqjfyIz1gipylg3r1diGcopU95wJs8i4b9k0965a4/s1600/log1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir8XuCwQw3NoGKZZs-UD3U6tT1B6peug0H-tYaf5kyvOIv83c_ZEqQwGV9D91wyh4QLoQRa2smj9tLuL4H_R_z1Mmz_BJlnJ0le7eqjfyIz1gipylg3r1diGcopU95wJs8i4b9k0965a4/s640/log1.png" width="640" /></a></div>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpBivjcMX7RxNcUZmNF4VEEeAxs46q4TN881NHYTJszdwioJ3c6fmuWYTiFNMI-X-dAA51OcAPlUEJyeRYY1wBEUNIaLKQkIeWGe2YhHbtCfPI295MOCc0e8Q8_kAWnpUCXFMwUAfpigQ/s1600/log.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpBivjcMX7RxNcUZmNF4VEEeAxs46q4TN881NHYTJszdwioJ3c6fmuWYTiFNMI-X-dAA51OcAPlUEJyeRYY1wBEUNIaLKQkIeWGe2YhHbtCfPI295MOCc0e8Q8_kAWnpUCXFMwUAfpigQ/s640/log.png" width="640" /></a></div>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span>
<span style="font-family: inherit;"><b><u><br /></u></b></span></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-4375256609114438122017-03-31T00:24:00.002-07:002017-03-31T00:25:50.228-07:00Magento 2 cannot login on frontend<div dir="ltr" style="text-align: left;" trbidi="on">
After installing Sample data on localhost, I was not able to login with the dummy user login.<br />
Am using xampp on windows 7, and working on Chrome browser.<br />
<br />
Recently I found I cannot add any products to cart and found a <a href="http://magehelper.blogspot.in/2017/03/magento-2-cannot-add-products-to-cart.html" target="_blank">solution for it.</a><br />
<br />
The same solution applies here. This issue is due to form key mismatch. As I suggested in previous post, this is recommended only for testing environment i.e only on your localhost.<br />
<br />
<h3 style="text-align: left;">
<b><u>Quick Fix.</u></b></h3>
<div>
<b><u><br /></u></b></div>
<div>
<div>
Go to <span style="font-family: "courier new" , "courier" , monospace;">vendor/magento/module-customer/Controller/Account/LoginPost.php execute() method.</span></div>
<div>
Comment out the first if condition which checks the session and posted form key.</div>
</div>
<div>
<br /></div>
<div>
<pre class="brush:php;">// if ($this->session->isLoggedIn() || !$this->formKeyValidator->validate($this->getRequest())) {
// /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
// $resultRedirect = $this->resultRedirectFactory->create();
// $resultRedirect->setPath('*/*/');
// return $resultRedirect;
// } </pre>
</div>
</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-82745090862406891232017-03-31T00:13:00.000-07:002017-03-31T00:26:09.367-07:00Magento 2 cannot add products to cart<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: inherit;">On <b>localhost environment</b>, there is this annoying issue on <b>CHROME browser</b>. When you add products to cart, you will see no errors displayed, but products will not be added to cart.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Few of the stack overflow post suggest to change the localhost URL to 127.0.0.1 OR adding a vhost entry to change the localhost url to something else. I have found a quick fix for this issue. This fix is not recommended for Production environment. This is only for the developers who are working on their local environment.</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<h3 style="text-align: left;">
<b style="font-family: inherit;"><u>Problem</u></b></h3>
<div>
<b style="font-family: inherit;"><u><br /></u></b></div>
<span style="font-family: inherit;">There is a form_key mismatch. Form key which gets posted during add to cart action and the stored Session value form key is mismatched.</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<h3 style="text-align: left;">
<b><u>Quick fix.</u></b></h3>
<div>
<b><u><br /></u></b></div>
Go to <span style="font-family: "courier new" , "courier" , monospace;">vendor/magento/module-checkout/Controller/Cart/Add.php execute() method.</span><br />
Comment out the first if condition which checks the session and posted form key.<br />
<br />
<pre class="brush:php;">//if (!$this->_formKeyValidator->validate($this->getRequest())) {
//return $this->resultRedirectFactory->create()->setPath('*/*/');
//}</pre>
</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-11914308171926001642015-06-03T06:17:00.001-07:002015-06-03T06:26:44.218-07:00Get system config values in magento 2<div dir="ltr" style="text-align: left;" trbidi="on">
How to get data from Magento 2 System Configuration ? Here's how to.<br />
<br />
We need to call the default method available.<br />
<br />
Just Use<span style="font-family: Courier New, Courier, monospace;"> \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,</span><br />
In your constructor argument and create an Object <span style="font-family: Courier New, Courier, monospace;">$this->scopeConfig = $scopeConfig;</span><br />
<br />
Now to Get the configuration value just use<br />
<span style="font-family: Courier New, Courier, monospace;">$this->_scopeConfig->getValue('dev/debug/template_hints', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);</span><br />
<br />
First argument is the value which we need from system configuration and the Second argument is the Store scope.<br />
<br />
<b><u>Demo</u></b><br />
<br />
<pre class="brush:php;">public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
) {
$this->_scopeConfig = $scopeConfig;
}
public function helloWorld(){
$showTemplateHint = $this->_scopeConfig->getValue('dev/debug/template_hints', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}
</pre>
</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-83551676622370135712015-05-29T00:13:00.001-07:002017-04-03T01:23:11.565-07:00Logging in magento 2 including FirePHP<div dir="ltr" style="text-align: left;" trbidi="on">
Magento 2 uses <b>Monolog</b> library to log messages. More information about the monolog is <a href="https://github.com/Seldaek/monolog" target="_blank">here</a><br />
<br />
You can find the Library package in the following location in Magento 2<br />
<span style="font-family: "courier new" , "courier" , monospace;">MAGENTO2_ROOT/vendor/monolog</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">Log files will be created inside var/log folder.</span><br />
<br />
To add logging to your class we need to add an instance of the monolog class. As magento 2 uses <b>Dependency Injection(DI) </b> we need to pass the instance in the constructor of your class.<br />
<br />
Just for testing, we are going to add this in one of the magento's default class. Go to <span style="font-family: "courier new" , "courier" , monospace;">app/code/Magento/Cms/Block/Page.php</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">And add the below lines After </span><span style="font-family: "courier new" , "courier" , monospace;">Protected $pageConfig</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<pre class="brush:php;">/**
* @var \Psr\Log\LoggerInterface
*/
protected $_logger;
</pre>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">And add this line </span><span style="font-family: "courier new" , "courier" , monospace;">\Psr\Log\LoggerInterface $logger,</span> <span style="font-family: inherit;"> as the parameter of the </span><span style="font-family: "courier new" , "courier" , monospace;">__construct() </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">Now we need to create an object. so add these line inside the function</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger = $logger;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addDebug('some text or variable');</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">So <b>Finally our Constructor function</b> will look like this.</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<pre class="brush:php;">public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Cms\Model\Page $page,
\Magento\Cms\Model\Template\FilterProvider $filterProvider,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Cms\Model\PageFactory $pageFactory,
\Magento\Framework\View\Page\Config $pageConfig,
\Psr\Log\LoggerInterface $logger,
array $data = []
) {
parent::__construct($context, $data);
// used singleton (instead factory) because there exist dependencies on \Magento\Cms\Helper\Page
$this->_page = $page;
$this->_filterProvider = $filterProvider;
$this->_storeManager = $storeManager;
$this->_pageFactory = $pageFactory;
$this->pageConfig = $pageConfig;
$this->_logger = $logger;
$this->_logger->addDebug('some text or variable');
}
</pre>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<b><u>TO USE FIREPHP LOGGING</u></b><br />
<b><u><br /></u></b>
Detailed Article <a href="http://magehelper.blogspot.com/2017/04/custom-logger-in-magento-2-firephp.html" target="_blank">here</a><br />
<b><u><br /></u></b>
Monolog has inbuilt FirePHP logging library. FirePHP is used to send log messages to the FireBug Console. More information <a href="https://github.com/firephp/firephp-core" target="_blank">here</a>. Install FirePHP Firefox / Chrome addon to use this.<br />
<br />
Now to <b>Use FirePHP in Magento 2</b> just use this line<br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->pushHandler(new \Monolog\Handler\FirePHPHandler());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></span>above<br />
<span style="font-family: "courier new" , "courier" , monospace;">$this->_logger->addDebug('some text here');</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">You can see the message available on the <b>Firebug Console panel</b>, instead of creating a log file.</span><br />
<br /></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-90579281568051102932015-05-22T00:11:00.000-07:002015-05-22T00:11:51.338-07:00Configurable Product not adding to cart <div dir="ltr" style="text-align: left;" trbidi="on">
Community edition 1.9 and Enterprise edition 1.14 both have this problem. There will be a memory exhausted issue or the browser keeps loading forever.<br />
<br />
There is a patch for this fix which is available on <a href="https://gist.github.com/piotrekkaminski/54529dadb0bc01a62a2d" target="_blank">github</a>.<br />
More discussion can be found on the <a href="http://magento.stackexchange.com/questions/37395/magento-debug-trace/44112" target="_blank">magento.stackexchange</a> website.<br />
<br /></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-17523944163217706892015-05-22T00:03:00.000-07:002015-05-22T00:03:55.373-07:00Remove maintenance mode in magento 2 <div dir="ltr" style="text-align: left;" trbidi="on">
Removing Maintenance mode in Magento 2 is extremely simple as in previous Magento versions.<br />
<br />
The <b>.maintenance.flag</b> file is located under <b>var folder </b>in Magento 2. Delete this file to remove the maintenance mode.</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-31514923994136139062015-01-22T03:33:00.000-08:002015-01-22T03:33:32.348-08:00Set / Change Meta title and description in Magento 2<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<u><b>SET PAGE META VIA BLOCK</b></u> <br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> </span><br />
You need to place this code inside your <span style="font-family: "Courier New",Courier,monospace;">_prepareLayout()</span> function in your<b> Block file</b><span style="font-family: inherit;">.<span style="font-family: inherit;"> Be<span style="font-family: inherit;">low is the complete <span style="font-family: inherit;">fu<span style="font-family: inherit;">nction.</span></span></span></span></span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">public function _prepareLayout()<br />{</span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span></span></span></span></span><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">//set page Meta's</span></span></span></span></span></span></span></span></span></span></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"> </span> </span></span></span></span></span>$this->pageConfig->setKeywords('Hello Metakeyword');</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> $this->pageConfig->setDescription('Hello Metadescription');</span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><br /> return parent::_prepareLayout();</span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">}</span> </span></span></span></span> </span><br />
<br />
<u><b>SET PAGE META VIA LAYOUT XML</b></u><br />
<br />
Open your xml file inside your layout folder and place this code above the body tag.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><head><br /> <meta name="description" content="XML Hello metadesc"/><br /> <meta name="keywords" content="XML Hello keywords"/></span><br />
<span style="font-family: "Courier New",Courier,monospace;"></head> </span><br />
<br />
<u><b>NOTE:</b></u> When you try to add title via both the methods first preference will be given to the block method(php file). </div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-57752853129696809442015-01-18T21:50:00.001-08:002015-01-19T05:07:25.262-08:00Set page title on Magento 2<div dir="ltr" style="text-align: left;" trbidi="on">
I was working on creating a simple Hello world module in Magento 2. Tutorials from other websites, there was only instructions to create the module and then I found the page title was empty.<br />
<br />
I did a little search in the core files and found the code to set page title.<br />
<br />
<u><b>SET PAGE TITLE VIA BLOCK</b></u> <br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$this->pageConfig->getTitle()->set(__('Hello World'));</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> </span><span style="font-family: "Courier New",Courier,monospace;"></span><br />
You need to place this code inside your <span style="font-family: "Courier New",Courier,monospace;">_prepareLayout()</span> function in your<b> Block file</b><span style="font-family: inherit;">.<span style="font-family: inherit;"> Be<span style="font-family: inherit;">low is the complete <span style="font-family: inherit;">fu<span style="font-family: inherit;">nction.</span></span></span></span></span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">public function _prepareLayout()<br />{</span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span></span></span></span></span><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">//set page title</span></span></span></span></span></span></span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"> </span> $this->pageConfig->getTitle()->set(__('Hello Index Test'));</span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><br /> return parent::_prepareLayout();</span></span></span></span></span></span><br />
<span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">}</span> </span></span></span></span> </span><br />
<br />
<u><b>SET PAGE TITLE VIA LAYOUT XML</b></u><br />
<br />
Open your xml file inside your layout folder and place this code above the body tag.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><head><br /> <title>SAMPLE TITLE</title></span><br />
<span style="font-family: "Courier New",Courier,monospace;"></head> </span><br />
<br />
<u><b>NOTE:</b></u> When you try to add title via both the methods first preference will be given to the block method(php file). <br />
<br /></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-30315317726376531912015-01-12T03:12:00.000-08:002016-10-19T05:10:11.952-07:00Set/Enable developer mode in Magento 2<div dir="ltr" style="text-align: left;" trbidi="on">
Magento 2 is already out for developers for testing and contributing improvements. After installing magento 2, you need to enable the Developer mode to show the errors on browser. Else, the errors will be logged into a separate file under <span style="font-family: "courier new" , "courier" , monospace;">var/report</span>.<br />
<br />
There are multiple ways to enable a developer mode<br />
<b><u>Via Console</u></b><br />
Run the following command <span style="font-family: Courier New, Courier, monospace;">"php bin\<span style="font-size: 0.9em;">magento deploy:mode:developer</span></span><span style="font-family: "monaco" , "menlo" , "consolas" , "courier new" , monospace; font-size: 0.9em;">"</span><br />
<div>
<br /></div>
<b><u>Edit env.php</u></b><br />
<span style="font-family: Courier New, Courier, monospace;">'MAGE_MODE' => 'developer</span>' add this line on your env.php file below 'x-frame-options'<br />
<br />
<b><u>OR</u></b><br />
Just add this below line on your index.php file<br />
<span style="font-family: "courier new" , "courier" , monospace;">$_SERVER['MAGE_MODE'] = 'developer';</span><br />
<br />
Place the code above on line 1. Above all the codes which was there already.</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-41595506764751864812015-01-07T05:59:00.006-08:002015-01-19T05:07:25.259-08:00Magento 2 Installation Guide.<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Magento 2</b> is under development phase and there are beta release on Github which are free to explore. You can download Magento 2 <b><a href="https://github.com/magento/magento2" target="_blank">here</a>.</b><br />
<br />
<u><b>INSTALLATION</b></u><br />
<br />
<b>*</b> Once you have downloaded magento2 zip file from Github, you can extract it to your htdocs folder(in xampp).<br />
<br />
<b>*</b> Next thing is to Install the <b><a href="https://getcomposer.org/download/" target="_blank">Composer</a></b>. Without installing composer we cannot run Magento 2.<br />
<br />
<b>*</b> Steps for Installing Composer on Windows machine can be found <b><a href="http://abuango.net/2014/08/16/how-to-install-composer-on-windows-with-xampp/" target="_blank">here</a>.</b> Follow steps from 1 to 5 if latest xampp version is installed.<br />
<br />
<b>*</b> Step for Installing Composer on Linux machine can be found <b><a href="https://alankent.wordpress.com/2014/08/02/magento-2-progress-towards-installation-via-composer/" target="_blank">here.</a></b><br />
<br />
<b>* </b>Once Composer is installed properly, Now you can install magento 2. Find the <b><i>composer.JSON</i></b> file inside your extracted magento 2 folder and Right click on it and select composer Install.<br />
<br />
<b>*</b> Now the composer will install the necessary library files and you are good to go.<br />
<br />
<b>*</b> Run the file via your Browser like the usual magento Installation.<br />
<br />
<br />
<b>NOTE:</b> Magento 2 requires PHP version 5.4 or higher.<br />
<br />
Complete installation instructions <u>with Screenshots</u> is available on <a href="http://blog.magestore.com/install-magento-2-updated-latest-version/" target="_blank">Magestore website.</a> <br />
<br />
You can get the <u><b>Usefull links to study</b></u> and get to know more about <u><b>Magento 2</b></u> from my next post. Click <b><a href="http://magehelper.blogspot.in/2015/01/magento-2-study-guide-useful-websites.html" target="_blank">here</a>.</b> </div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-82135375994153036232015-01-07T05:58:00.003-08:002015-01-22T23:03:35.076-08:00Magento 2 study guide & useful websites to get to know about it<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
The new version of Magento has a significant changes in the architecture when comparing to its 1.* versions. I have started learning Magento 2 and found some of the websites that explains the changes and improvements very clearly. These are from the Masters of Magento.<br />
<br />
Am not going to explain the changes that are in Magento 2, instead I will give you all the Links that are useful for you to explore and learn it by yourself. <br />
<br />
<u><b>OFFICIAL WIKI</b></u><br />
It's good to have the Magento have their own well formatted Wiki for Magento 2. The Wiki explains all the technology changes in Magento 2. You can go to the Official WIKI page <b><a href="https://wiki.magento.com/display/MAGE2DOC/Developer%27s+Guide" target="_blank">here</a>.</b><br />
<br />
<u><b>THE MASTERS</b></u> <br />
<br />
I have also found other websites that are extremely useful to study magento 2. They are,<br />
<b>* </b>The <b><a href="https://alankent.wordpress.com/category/magento/page/2/" target="_blank">Alan Kent's Blog. (Magento's chief architect)</a></b><br />
<b>* </b>The Inchooers <b><a href="http://inchoo.net/category/magento-2/" target="_blank">website.</a></b><br />
<b>* </b>Magestore's <b><a href="http://blog.magestore.com/magento-2/" target="_blank">website.</a> </b><br />
<b>* </b>An Awesome explanation for Dependency Injection(DI) can be found <b><a href="http://fabien.potencier.org/article/11/what-is-dependency-injection" target="_blank">here.</a></b> The website explains the DI for Symphony, Yet the concept for the DI is the Same for all. More explanation for DI can be found from the <b><a href="http://www.procata.com/talks/phptek-may2007-dependency.pdf" target="_blank">Jeff More Presentation.</a></b><br />
<br />
<b><u>START EXPLORING WITH THESE INITIATIVES</u></b><br />
<br />
<b>Magestore</b> have developed a <b>banner module</b> for Magento 2. You can visit their website<b><a href="http://blog.magestore.com/explore-magento-2-0-with-banner-slider-extension/" target="_blank"> here</a></b> to View the Demo and download the banner module.<br />
<br />
You can get the <b>THEME for Magento 2</b> <b><a href="http://www.ubertheme.com/magento-themes/crafts-magento-2-theme/" target="_blank">here.</a></b> Uber theme offers this free Magento 2 theme and the Live Demo of the theme can be found on the link provided.<br />
<br />
<u><b>SAMPLE DATA FOR MAGENTO 2</b></u><br />
<br />
Uber theme also provides the Sample data for magento 2. You can visit their website <b><a href="http://www.ubertheme.com/magento-news/magento-2-demo-sample-data-admin-access/" target="_blank">here.</a> </b>This website clearly explains the installation steps and configuring magento 2 with Screenshots.<br />
<br />
Go crazy on New Magento 2.<br />
<b> </b></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-44174643269073695792014-12-19T06:00:00.003-08:002015-01-19T05:05:50.436-08:00Magento remove selected items from shopping cart<div dir="ltr" style="text-align: left;" trbidi="on">
When you have too many products in you shopping cart and you want to remove particular products out of it, you only need to do it one-by-one. And its really frustrating especially for testers. Magento does not provide the feature to remove selected products by default.<br />
<br />
I have developed a code that could allow users to select the products which they want to remove by simply checking the products and click the remove button. And they all will be removed at a time.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitENCeaoJemr33UDDfhJMIrtFobZX7tJbG0EWEmX85PbG6-_VuSBPQx64mF_MIta-VtnAWXQbGq6rDmugDh-JYb1uADtYoeVV7VV1WLtBFw_eC4dfCjYbNrkz0kjSYJBsemDDcsAL-3TA/s1600/magento+remove+selected+item.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitENCeaoJemr33UDDfhJMIrtFobZX7tJbG0EWEmX85PbG6-_VuSBPQx64mF_MIta-VtnAWXQbGq6rDmugDh-JYb1uADtYoeVV7VV1WLtBFw_eC4dfCjYbNrkz0kjSYJBsemDDcsAL-3TA/s1600/magento+remove+selected+item.png" height="163" width="640" /></a></div>
<br />
<b>Please download the extension</b> <b><a href="https://www.dropbox.com/s/ne0oqabrrszncwg/Magentohelper_removeselected.zip?dl=0" rel="nofollow" target="_blank">here</a></b>. Extract it and move it inside appropriate folders.<br />
Tested on Version 1.7.2 and 1.8.1 community edition.</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-70790537278713476622014-12-08T02:02:00.000-08:002015-03-13T22:39:33.448-07:00Magento update backorder programatically<div dir="ltr" style="text-align: left;" trbidi="on">
To update a products backorder status i wrote a custom script. My script reads the SKU's from the csv file and checks if the product exists and updates its backorder status.<br />
<br />
Below is the code.<br />
<br />
<pre class="brush:php;">
$products = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);<br />
if($products)<br />
{ <br /> // get product's stock data such quantity, in_stock etc<br /> $stockData = Mage::getModel('cataloginventory/stock_item')->loadByProduct($products);<br /> <br /> //to update backorder<br /> $stockData->setData('use_config_backorders', '0'); //not to use config settings <br /> /*0 = No Backorders<br /> 1 = Allow Qty Below 0<br /> 2 = Allow Qty Below 0 and Notify Customer*/<br /> $stockData->setData('backorders', '1'); <br /> <br /> // then set product's stock data to update<br /> $stockData->save();<br /> <br /> // call save() method to save your product with updated data<br /> $products->save(); <br />
}</pre><br />
<br />
<b>You can download the complete code <a href="https://www.dropbox.com/s/3sfnvybp1ynftvk/update-backorder.php?dl=0" rel="nofollow" target="_blank">here</a>.</b> It reads the csv file and checks for the products, If it is found the data are updated. Upon running this file. It will output all the products status (Found, Not found, How many not found) in the webpage. It also Writes the missing sku's in a new CSV file.</div>dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-9042741861036428862014-11-25T04:50:00.000-08:002015-01-19T05:05:50.468-08:00Magento CSV import error show which row value is skipped<div dir="ltr" style="text-align: left;" trbidi="on">
During the Batch CSV import, some of the rows will be skipped due to missing required values or any such errors. On the import process page magento will throw error message like below by default.<br />
<br />
<b>BEFORE</b> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjodUINNvYnlTjYQkQHvrvr33hOLLSHLHriAxyc7Xm_-new0VFDvefb_3lHaS-3r9VxlseKAcQKEn00s2LdjpQjpF4vax3ksOp1bSFNXsO5pLcR_vMC3ZrLL2mpFST1p1cqfds6chZWr9g/s1600/batch-error-default.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjodUINNvYnlTjYQkQHvrvr33hOLLSHLHriAxyc7Xm_-new0VFDvefb_3lHaS-3r9VxlseKAcQKEn00s2LdjpQjpF4vax3ksOp1bSFNXsO5pLcR_vMC3ZrLL2mpFST1p1cqfds6chZWr9g/s1600/batch-error-default.png" height="22" width="320" /></a></div>
From this error message we won't be able to identify exactly which row is skipped. So I have made a modification to the magento files and after that<br />
<br />
<b>AFTER</b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_hCZR_-qFiylqrAcG_5FrQfATxRI_XWOIP-D6EkLC32RHJc3DoNkpcjuTusxiOhyphenhyphenCC5S_Lsz5MHQQ4BgX4DGsXoB9lm38mgGjIXM7-EgtD5jBJRj3MnF1TjQBUZijdaphOA5khSG8k0Q/s1600/batch-error.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_hCZR_-qFiylqrAcG_5FrQfATxRI_XWOIP-D6EkLC32RHJc3DoNkpcjuTusxiOhyphenhyphenCC5S_Lsz5MHQQ4BgX4DGsXoB9lm38mgGjIXM7-EgtD5jBJRj3MnF1TjQBUZijdaphOA5khSG8k0Q/s1600/batch-error.png" height="24" width="640" /></a></div>
<br />
Now we will know which row is skipped and can check for errors in it. Let me explain the few modification which i did to achieve this.<br />
<br />
<h3 style="text-align: left;">
<u><b>Step 1:</b></u></h3>
copy the file Customer.php which is under the path <span style="font-family: "Courier New",Courier,monospace;">"app/code/core/Mage/Customer/Model/Convert/Adaptor/" <span style="font-family: inherit;">to this path </span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">"app/code/local/Mage/Customer/Model/Convert/Adaptor/"</span></span></span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">DO NOT EDIT THE CORE FILE. ALWAYS OVERRIDE IT USING LOCAL FOLDER </span></span></span><br />
<br />
<h3 style="text-align: left;">
<u><b>Step 2:</b></u></h3>
open the Customer.php in your editor and look for the function name "saveRow". It will be around line 418.<br />
Inside this function you will see the error messages text. For Example:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined. ', 'website');</span><br />
<br />
Replace above line with this. <br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;"> $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined. Unique value to identify in CSV <strong>%s</strong> ', 'website', $importData['email']);</span><br />
<br />
There will be similar error messages thrown for various reasons like customer group not found. website id does not exist and so on.. You can use the above customization to all those errors thrown.<br />
<br />
The $importData['email'] is the one which contains the row value which is unique in case on Customer import. you can also use $importData['firstname'] or $importData['lastname'] according to your needs. The values inside the quotes are the column names from the CSV.<br />
<br />
Similarly For Product batch import you can modify the file which is under. <span style="font-family: "Courier New",Courier,monospace;">app/code/core/Mage/Ccatalog/Model/Convert/Adaptor/Product.php<span style="font-family: inherit;"> </span> </span><br />
<br />
<i>NOTE: When you import the CSV. look for any Special characters. This may cause errors during import. To import CSV with special characters edit your .htaccess file and add this line to it AddDefaultCharset UTF-8</i><br />
<br /></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-39658732629465333522014-11-25T03:30:00.002-08:002015-03-13T22:35:36.281-07:00Magento Customer Import - Convert plain text password to magento format.<div dir="ltr" style="text-align: left;" trbidi="on">
One of my recent task is to import about 10k customers into Magento database. <br />
<br />
First thing came into my mind is to export the existing customer from magento and use the csv file to fill in the new customer values and import them back.<br />
But after exporting the few existing customers, i came to know that the CSV header fields which Magento exported is not suitable for the import and missing fields for password, customer address etc.<br />
<br />
After few searches, i found this SAMPLE CSV file. <a href="https://www.dropbox.com/s/lfbp2vh9bygmm5b/customer-import-example.csv?dl=0" rel="nofollow" target="_blank">click to download</a><br />
<br />
Filled in the CSV file and for the password_hash field, I had to develop a customer script to convert plain text password to Magento format password.<br />
<br />
My custom script is below. It reads the CSV file which contains plain text password, Encrypts it and writes to a new CSV file. After you CSV file is ready go to the admin panel. In the menu select System -> Import/Export -> Dataflow- Profiles. You will see "import customer". Click on it and upload your CSV file and click "save & continue edit" button. Then Choose the imported file from the dropdown and click Run.<br />
<br />
All the customers will be imported with their previous password and addresses.<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><pre class="brush:php;"><?php<br />$row = 1;<br />$fp = fopen('var/log/ss1-pass.csv', 'w');<br />$csvHeader = array('Text','Encrypted');<br />fputcsv( $fp, $csvHeader,",");<br /><br />//generate random string for salt<br />function generateRandomString($length = 2) {<br /> $characters = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';<br /> $randomString = '';<br /> for ($i = 0; $i < $length; $i++) {<br /> $randomString .= $characters[rand(0, strlen($characters) - 1)];<br /> }<br /> return $randomString;<br />}<br /><br />if (($handle = fopen("ss1.csv", "r")) !== FALSE) {<br /><br /> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {<br /> $row++;<br /> $plainText = trim($data[0]);<br /> $salt = generateRandomString(2);<br /> $encrypted = md5($salt.$plainText).":".$salt; <br /> fputcsv($fp, array($plainText,$encrypted), ",");<br /> //if($row==20){break;}<br /> }<br /> <br /> fclose($handle);<br /> fclose($fp);<br />}<br />?></pre></span><br />
<br /></div>dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-91002446998549991442014-07-18T05:38:00.002-07:002015-01-19T05:05:50.471-08:00Magento fedex SoapFault exception<div dir="ltr" style="text-align: left;" trbidi="on">
Well, when it comes to any third party Shipping API's it a big headache for the developers. Especially when the worlds largest Shipping company FedEx changed their URL for the webservice request without any prior notification and the URL's are hardcoded.<br />
<br />
So, How does it affect Magento ?<br />
<br />
I was using the FedEx shipping method and everything works good in the Frontend of the website. But when i create a Shipping Label from the Admin i got an error message "An error occured while creating shipping label". And when i checked the LOG file, there was only EXCEPTION log created.<br />
<br />
Ok, so after checking the exception log i found that there was a "SoapFault exception" error.<br />
Later i found that it was the FedEx the culprit.<br />
<br />
<b>FIXES</b><br />
<br />
Go to the path: app/code/core/Mage/Usa/Model/Shipping/Carrier<br />
open Fedex.php file<br />
<br />
On the line number 135 you will find such code with the fedex webservice url hardcoded<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$client->__setLocation($this->getConfigFlag('sandbox_mode')<br /> ? 'https://wsbeta.fedex.com:443/web-services/rate'<br /> : 'https://ws.fedex.com:443/web-services/rate'<br /> );</span><br />
Replace this with this new code.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$client->__setLocation($this->getConfigFlag('sandbox_mode')<br /> ? 'https://wsbeta.fedex.com:443/web-services'<br /> : 'https://ws.fedex.com:443/web-services'<br /> );</span><br />
<br />
and that's it. The error must be Fixed. If it still exists please check your server configuration for the SOAP and WSDL configuration. It must be using older version. Try upgrading it.<br />
<br />
<b>NOTE: </b>If you are creating Shipping Labels you Need to change the URL on the WSDL file also. The URL will be found at the very bottom of the code. </div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-69113638991962797142014-07-01T04:54:00.001-07:002015-01-19T05:05:50.452-08:00Magento Add to cart not working for new products block<div dir="ltr" style="text-align: left;" trbidi="on">
I came across this Add to cart issue after upgrading from version 1.7.2 to 1.8.1.<br />
Then after a long time search, luckly i found the cause.<br />
<br />
In Magento version 1.8.1 there was an update to the add to cart feature with the inclusion of "Form keys". Magento has implemented this feature to prevent XSS attacks.<br />
<br />
To know more about Form keys <a href="http://code.tutsplus.com/tutorials/secure-your-forms-with-form-keys--net-4753">click here.</a><br />
<br />
<b>SOLUTION</b> : Change the button type from "button" to "submit"<br />
<br />
<b>NOTE</b> : Enabling All cache type may not solve the issue. Disable only "Blocks HTML output", you can enable other cache types.</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-70869583903611866802014-02-19T03:08:00.001-08:002015-01-19T05:05:50.458-08:00USPS API update january 2014<div dir="ltr" style="text-align: left;" trbidi="on">
Usps have updated their API on January 2014. You can find the details of it <a href="http://j.mp/18dTBs1" target="_blank">here</a><br />
<br />
And for those who have registered for the USPS developer or production account you would have been received mail from Usps about the API update.<br />
<br />
According to the new update the shipping method "Standard Post" has been eliminated for Zones 1 to 4<br />
<br />
Usps separates zipcodes with their zones. You can find your zone from here. <a href="http://postcalc.usps.gov/ZoneCharts/" target="_blank">FIND USPS ZONES</a><br />
Go to "Get Zone for ZIP Code Pair" tab and enter your Origin and Destination zip code.<br />
<br />
If your zone is numbered from 1 to 4, the "Standard Post" shipping method will not be applicable for you zipcode. Exception is given when you ship hazardous materials, live animals or other ground only items.<br />
<br />
You can find more info about the API changes. <a href="https://www.blogger.com/business/web-tools-apis/2014-january-webtools-release-notes.rtf" target="_blank">2014 January Release Notes (RTF)</a></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-28328982983452990312014-02-06T04:53:00.000-08:002015-01-19T05:05:50.419-08:00Magento change product image on view page to associated product image<div dir="ltr" style="text-align: left;" trbidi="on">
Magento's configurable product does not load its associated product image when we change the attribute value. To change the image of the product respective to the selected attribute value i have used this code. Magento website also offers a wiki to achieve this, but its pretty old and its written for magento version 1.5 and below. <a href="http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/change_product_image_on_view_page_to_associated_product_s_image" target="_blank">Link to wiki</a><br />
<br />
I have tested this code in recent magento version which is 1.8 and the most famous 1.7.<br />
<br />
Here is the code.<br />
<b><br /></b>
<b>STEP 1:</b><br />
<br />
Open template/catalog/product/view.phtml<br />
<br />and find the line <span style="font-family: "Courier New",Courier,monospace;">var productAddToCartForm = new VarienForm('product_addtocart_form');</span> on the bottom of the page.<br />
<br />
Add these code on top of that line.<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">var mainProductImgSrc = document.getElementById("image").src;</span><br />
<span style="font-family: "Courier New", Courier, monospace;">var assocIMG =<br /><br /><?php<br />if ($_product->getTypeId() == "configurable") {<br />echo "{";<br />$associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();<br />foreach ($associated_products as $assoc)<br />$dados[] = $assoc->getId().":'".($assoc->image == "no_selection" || $assoc->image == "" ? $this->helper('catalog/image')->init($_product, 'image', $_product->image)->resize(365,400) : $this->helper('catalog/image')->init($assoc, 'image', $assoc->image)->resize(365,400))."'";<br />} else {<br />$dados[] = "";<br />}<br />echo implode(',', $dados );<br />if ($_product->getTypeId() == "configurable") {<br />echo "}";<br />}<br /><br />?></span><br />
<br />
<b><span style="font-family: inherit;">STEP 2:</span></b><br />
<br />
open js/varien/product.js and find the line<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">}.bind(this));<br />for (var i = 0; i < this.tierPrices.length; i++) {</span><br />
<br />
<span style="font-family: inherit;">and add the below given code above this-> " <span style="font-family: "Courier New",Courier,monospace;">}.bind(this)); " line.</span></span><br />
<br />
<span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">//to change product image based on option select for configurable product</span></span><br />
<span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">settings = $$('.super-attribute-select');</span></span><br />
<span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">imgSrc = mainProductImgSrc;</span></span><br />
<span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">settings.each(function(element)<br /> {<br /> attributeId = element.attributeId;<br /> if(element.options[element.selectedIndex].config)<br /> imgSrc = assocIMG[element.options[element.selectedIndex].config.products];<br /> $('image').src = imgSrc;<br /> });</span></span><br />
<span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">//ends</span></span><br />
<br />
<span style="font-family: inherit;">Your are done now. Do remember to select the base image for the associated product. If there is no image set for the associated product and when you change the option the configurable product image will be used instead.</span><br />
<br /></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-82116391462716886082014-02-01T05:23:00.000-08:002015-01-19T05:05:50.461-08:00Magento import products with custom product type via csv<div dir="ltr" style="text-align: left;" trbidi="on">
I was assigned a job to import products with custom product types through CSV<br />
<br />
Magento's default product types are<br />
<ol style="text-align: left;">
<li>simple</li>
<li>configurable</li>
<li>virtual</li>
<li>grouped</li>
</ol>
But when you import products with new product type other than the above mentioned. you will get this error<br />
<br />
<pre class="default prettyprint prettyprinted"><code><span class="pln"></span><span class="typ">Product</span><span class="pln"> </span><span class="typ">Type</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> invalid </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> supported </span><span class="kwd">in</span><span class="pln"> rows... </span></code></pre>
<br />
To overcome this error and import products with your custom product type you must follow these two steps.<br />
<br />
1. Now am going to assume you have created an extension. On the config.xml file of your extension place this code under <span style="font-family: "Courier New",Courier,monospace;"><global></span> tag.<br />
<br />
<code><importexport><br /> <import_product_types><br /> <YOUR_MODULE>yourModule/import_entity_product_type_</code><code><code>YOUR_MODULE</code></</code><code><code>YOUR_MODULE</code>><br /> </import_product_types></code><br />
<code></importexport></code><br />
<br />
Replace YOUR_MODULE with you module name.<br />
<br />
2. Create a new model class to do the import. For this create this folder structure inside your model structure<br />
<span style="font-family: "Courier New",Courier,monospace;"><code>Import\Entity\Product\Type\NEW-PRODUCT-TYPE</code></span><br />
<br />
In my case i have a new product type "<span style="font-family: "Courier New",Courier,monospace;">subscription_simple</span>". so my folder structure will be <br />
<span style="font-family: "Courier New",Courier,monospace;">Import\Entity\Product\Type\Subscription\</span><br />
<br />
Inside the folder i have a model class <span style="font-family: "Courier New",Courier,monospace;">Simple.php</span> file extending the magneto import class.\<br />
<br />
place this code inside Simple.php file.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">class NAMESPACE_MODULE_Model_Import_Entity_Product_Type_Subscription_Simple</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;"> extends Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">{</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">}</span><br />
<br />
Now you can do the import with your custom product type.<br />
<br />
you can check out one of the inbuilt classes for an example <code>Mage_ImportExport_Model_Import_Entity_Product_Type_Simple</code><br />
<br />
INFO: <a href="http://stackoverflow.com/questions/8909405/product-type-is-invalid-or-not-supported-in-rows-for-custom-product-type" target="_blank">http://stackoverflow.com/questions/8909405/product-type-is-invalid-or-not-supported-in-rows-for-custom-product-type</a></div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-56389803968701606072013-12-02T05:39:00.000-08:002015-01-19T05:05:50.442-08:00[SOLVED] Magento - fedex not showing all the shipping methods<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I was wondering why all the Shipping methods in FedEx which i have selected is not shown on the frontend. Well here is the answer.<br />
<br />
FedEx returns the list of shipping methods as a response for our API call. The response is based on the total products weight (sum of all the products weight in cart).<br />
<br />
So if the total weight is upto 70lbs Ground Shipping will be shown. If the weight is more than 70lbs you can use Home delivery. And if the weight is above 150lbs you can use freight methods.</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0tag:blogger.com,1999:blog-5204060239509440430.post-11594439845264847622013-11-08T01:57:00.000-08:002015-01-19T05:05:50.413-08:00Magento- Fedex shipping methods service codes.<div dir="ltr" style="text-align: left;" trbidi="on">
There is no proper documentation available for FedEx web services API. I wanted to know the different service codes for shipping. Took a long search, but its is not available even in Fedex website which has examples only with priority shipping methods. So i went on a deep search and found this.<br />
<br />
These are the list of FedEx web services API service code values for different shipping methods.<br />
<br />
'INTERNATIONAL_PRIORITY'<br />
'EUROPE_FIRST_INTERNATIONAL_PRIORITY'<br />
'INTERNATIONAL_ECONOMY'<br />
'STANDARD_OVERNIGHT'<br />
'FIRST_OVERNIGHT'<br />
'PRIORITY_OVERNIGHT'<br />
'FEDEX_2_DAY' <br />
'FEDEX_GROUND'<br />
<br />
'GROUND_HOME_DELIVERY'<br />
'INTERNATIONAL_GROUND'<br />
'FEDEX_EXPRESS_SAVER'<br />
'FEDEX_FREIGHT'<br />
<br />
'FEDEX_NATIONAL_FREIGHT'<br />
'FEDEX_1_DAY_FREIGHT'<br />
'FEDEX_2_DAY_FREIGHT'<br />
'FEDEX_3_DAY_FREIGHT'<br />
'INTERNATIONAL_ECONOMY_FREIGHT'<br />
'INTERNATIONAL_PRIORITY_FREIGHT'<br />
'SMART_POST'</div>
dkfranchttp://www.blogger.com/profile/07435222747960838082noreply@blogger.com0