<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5862994791655053372</id><updated>2025-08-31T05:14:24.920-07:00</updated><category term="magento"/><category term="php"/><category term="Magento2"/><category term="jQuery"/><category term="javascript"/><category term="Configurable Product"/><category term="Product Custom Option"/><category term="magento beginner"/><category term="magento module"/><category term="Image slider"/><category term="Mobile theme"/><category term="Product Details"/><category term="api"/><category term="category"/><category term="create module"/><category term="magento connect"/><category term="AngularJS"/><category term="Cart Page"/><category term="Configurable Product Options"/><category term="Custom Options"/><category term="Display Product"/><category term="Hide “Out of Stock” Products"/><category term="Magento product review"/><category term="Out Of Stock"/><category term="Product Images"/><category term="Product Listing page"/><category term="Product listing"/><category term="SKIN URL"/><category term="Simple Product SKU"/><category term="Store admin email address/name"/><category term="Template Path Hints"/><category term="customer"/><category term="discount / coupon"/><category term="dropdown"/><category term="featured products"/><category term="header"/><category term="home page"/><category term="htaccess"/><category term="htaccess Password"/><category term="html"/><category term="invoice"/><category term="magento pagination"/><category term="order"/><category term="order collection"/><category term="php csv script"/><category term="php file upload"/><category term="product custom option swatches"/><category term="registration"/><category term="rel=&quot;next&quot;"/><category term="rel=&quot;prev&quot;"/><category term="review form"/><category term="send newsletter"/><category term="simple product id"/><category term="#instock"/><category term="#magento #newsletter not sending"/><category term="#outofstock"/><category term="#swatches"/><category term=".html"/><category term=".phtm in Dreamweaver for XP"/><category term="Add New"/><category term="Add active class"/><category term="Admin"/><category term="Browser name"/><category term="Browser version"/><category term="CRUD"/><category term="Catalog Search"/><category term="Category Attributes"/><category term="Category Name"/><category term="Category tree"/><category term="Checkout/cart"/><category term="Company column"/><category term="Convert large number"/><category term="Custom"/><category term="Email Validation"/><category term="Express"/><category term="Host name"/><category term="Import Database"/><category term="Instagram"/><category term="MEDIA URL"/><category term="Magento Base url"/><category term="Magento mobile theme"/><category term="MongoDB"/><category term="Mouseover"/><category term="Multi Level Category"/><category term="Mysql"/><category term="Oauth"/><category term="Operating system name"/><category term="Option value"/><category term="Override/Rewrite"/><category term="PHP download multiple files"/><category term="Partial Invoice"/><category term="Prestashop cache or recompile manually"/><category term="Print"/><category term="Product #Custom #Option with Option #Swatches"/><category term="Product Count"/><category term="Product SKU"/><category term="Product attributes"/><category term="Products Grid"/><category term="Protect Folder"/><category term="Recursive function"/><category term="Redirect"/><category term="Region"/><category term="Remove limits"/><category term="Result Controller"/><category term="Retina Graphics"/><category term="STORE URL"/><category term="Selected category"/><category term="Social Share"/><category term="Switch  Product images"/><category term="Tumblr"/><category term="USER_AGENT"/><category term="Vista &amp; Mac"/><category term="Win7"/><category term="YouTube"/><category term="YouTube API"/><category term="account page"/><category term="action"/><category term="add exception"/><category term="advanced search"/><category term="age verification"/><category term="ajax function"/><category term="android"/><category term="attachment"/><category term="attribute ID"/><category term="attribute Value"/><category term="base theme"/><category term="billing address"/><category term="cart"/><category term="cart rule"/><category term="category attribute"/><category term="category page"/><category term="category search"/><category term="color swatches"/><category term="column"/><category term="command prompt"/><category term="contents of DIV"/><category term="controller"/><category term="controllers"/><category term="cookies"/><category term="core blocks"/><category term="count characters"/><category term="country"/><category term="create address"/><category term="create customer"/><category term="create new theme"/><category term="css"/><category term="currency switcher"/><category term="customer Grid"/><category term="download module creator magento"/><category term="emails"/><category term="extract zip files"/><category term="facebook"/><category term="facebook like"/><category term="followers"/><category term="freewall"/><category term="google"/><category term="group"/><category term="image change"/><category term="in stock"/><category term="in stock product"/><category term="ipad"/><category term="iphone"/><category term="jQuery ajax cross domain"/><category term="jquery print div content"/><category term="label"/><category term="list page"/><category term="list view"/><category term="login"/><category term="magento blog extension"/><category term="magento create invoice programmatically"/><category term="magento custom options quantity"/><category term="magento customers"/><category term="magento get product options"/><category term="mail"/><category term="module"/><category term="new columns"/><category term="noCAPTCHA"/><category term="node"/><category term="nodejs"/><category term="order Grid"/><category term="out of stock products"/><category term="page limit"/><category term="pass multiple data to ajax"/><category term="php  script"/><category term="php resize image"/><category term="product"/><category term="product filter option"/><category term="product tabs"/><category term="products"/><category term="products fields"/><category term="queue"/><category term="random product listing"/><category term="reCAPTCHA"/><category term="related product"/><category term="responsive"/><category term="role"/><category term="router"/><category term="scrolldown"/><category term="send email"/><category term="session"/><category term="shipping address"/><category term="sidebar"/><category term="top navigation"/><category term="user"/><category term="wishlist collection magento"/><category term="xml file"/><title type='text'>HKblog, Tutorials, jQuery, Ajax, PHP, MySQL, Magento, Magento 2</title><subtitle type='html'>HKBlog is a programming blog maintained by Hardik Patel. Tutorials focused on Programming, Magento, Magento 2, Magento Customization, Magento Extension, Jquery, Ajax, PHP, Web Design, Javascript, MySQL.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>128</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-3755493119649214060</id><published>2019-01-02T10:24:00.001-08:00</published><updated>2019-12-10T22:33:49.593-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><category scheme="http://www.blogger.com/atom/ns#" term="product custom option swatches"/><title type='text'>Product Custom Option Swatches For Magento 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;display: none;&quot;&gt;
Product Custom Option Swatches For Magento 2, Product Option Swatches + Magento 2, Magento 2 : How to display swatches, custom option swatches, drop-down option swatches, How to Get Product Custom Option In Product Listing Page in Magento 2, color swatches for magento 2, swatches in magento2, m2&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
3 years back i have created a module &lt;a href=&quot;http://hkpatel201.blogspot.com/2012/09/get-product-custom-option-in-list-page.html&quot; target=&quot;_blank&quot;&gt;Product Custom Option (Pro) with Option Swatches&lt;/a&gt; to display product custom option swatches instead of dropdown. Now i have created almost same module for &lt;b&gt;Magento 2&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Using my new module you can display &lt;b&gt;option swatches&lt;/b&gt; on product details page by replacing drop-down custom options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtm06b1E-rELhVyGLuBwuQRlMugvTw1x-p4_lhhJZ_sTqGns4pM_-bS528FMYlEZGsAr7W1IUHDsnEPKkHr89Iigmy90UsHi3zs-fZoYNnFoNn1pV37HF2pU-9QMbxA9PdArQ1FUrIPR0/s1600/product_custom_option_swatches.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Magento2&quot; border=&quot;0&quot; data-original-height=&quot;569&quot; data-original-width=&quot;1120&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtm06b1E-rELhVyGLuBwuQRlMugvTw1x-p4_lhhJZ_sTqGns4pM_-bS528FMYlEZGsAr7W1IUHDsnEPKkHr89Iigmy90UsHi3zs-fZoYNnFoNn1pV37HF2pU-9QMbxA9PdArQ1FUrIPR0/s640/product_custom_option_swatches.png&quot; title=&quot;Product Custom Option Swatches For Magento 2&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing this module, you will find new tab in your store configuration section. From here you can add option setting.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDX3a_5TDuzpLG4jt7WadhlCLtD_iIGSzV_vmPCAN8CngjcKHp49S1Qz8v7nU6_Lfu0xIKNPFgd4ps_JfJic-LtULlbV8266OJujs8O6VcqhlVN_cnMFUPlEDBU3PN4JEDdrMIA3aO3QE/s1600/hk_custom_option_swatches.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;522&quot; data-original-width=&quot;1098&quot; height=&quot;304&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDX3a_5TDuzpLG4jt7WadhlCLtD_iIGSzV_vmPCAN8CngjcKHp49S1Qz8v7nU6_Lfu0xIKNPFgd4ps_JfJic-LtULlbV8266OJujs8O6VcqhlVN_cnMFUPlEDBU3PN4JEDdrMIA3aO3QE/s640/hk_custom_option_swatches.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Run following command after installing module file in your magento.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;php bin/magento setup:upgrade&lt;br /&gt;php bin/magento setup:static-content:deploy&lt;br /&gt;php bin/magento cache:clean&lt;br /&gt;php bin/magento cache:flush&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;newsharepost-1 downloadlink&quot; href=&quot;https://www.dropbox.com/s/2kbaqk1s2svwl7u/HK_CustomSwatches.zip&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
Please post your comment if you have any issue.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/3755493119649214060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2019/01/product-custom-option-swatches-magento2.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3755493119649214060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3755493119649214060'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2019/01/product-custom-option-swatches-magento2.html' title='Product Custom Option Swatches For Magento 2'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtm06b1E-rELhVyGLuBwuQRlMugvTw1x-p4_lhhJZ_sTqGns4pM_-bS528FMYlEZGsAr7W1IUHDsnEPKkHr89Iigmy90UsHi3zs-fZoYNnFoNn1pV37HF2pU-9QMbxA9PdArQ1FUrIPR0/s72-c/product_custom_option_swatches.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-7610957682103107950</id><published>2018-12-27T04:47:00.000-08:00</published><updated>2018-12-27T21:41:48.570-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AngularJS"/><title type='text'>Add custom class to body depending on a component - Angular</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Sometimes the app that is being developed requires different classes on body of html document for styling each route or page. This can be achieved in Angular 2, Angular 4 and above using the following snippet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Home Component&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js&quot;&gt;...//other code above
export class HomeComponent implements OnInit, OnDestroy {
 ngOnInit(){
    const body = document.getElementsByTagName(&#39;body&#39;)[0];
    body.classList.add(&#39;page-home&#39;);
  }

  ngOnDestroy(){
    const body = document.getElementsByTagName(&#39;body&#39;)[0];
    body.classList.remove(&#39;page-home&#39;);
  }
...//other code below
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Dashboard Component&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js&quot;&gt;...//other code above
export class DashboardComponent implements OnInit, OnDestroy {
 ngOnInit(){
    const body = document.getElementsByTagName(&#39;body&#39;)[0];
    body.classList.add(&#39;page-dashboard&#39;);
  }

  ngOnDestroy(){
    const body = document.getElementsByTagName(&#39;body&#39;)[0];
    body.classList.remove(&#39;page-dashboard&#39;);
  }
...//other code below
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/7610957682103107950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/12/add-custom-class-to-body-angular.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7610957682103107950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7610957682103107950'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/12/add-custom-class-to-body-angular.html' title='Add custom class to body depending on a component - Angular'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-3822796632933109504</id><published>2018-12-04T05:30:00.000-08:00</published><updated>2018-12-04T05:32:03.249-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AngularJS"/><title type='text'>AngularJS First Basic Demo For Beginners</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this demo we are going to use a simple text box, label and one button. This demo is for beginners.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW-wbdCdbtWR38SKJit3P-woJJwkWWFGKyhq1AoRC8IbUJnuOvS0GiFwl-iYv99pOzE26T16shXDM09GlGu6e9PpjulXp9K-j8p5XRpoiayJqG9paGuFYspMpgyGxBFNE8q3XxJs1xp1Q/s1600/angularjs-first-basic-demo-for-beginners.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;272&quot; data-original-width=&quot;573&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW-wbdCdbtWR38SKJit3P-woJJwkWWFGKyhq1AoRC8IbUJnuOvS0GiFwl-iYv99pOzE26T16shXDM09GlGu6e9PpjulXp9K-j8p5XRpoiayJqG9paGuFYspMpgyGxBFNE8q3XxJs1xp1Q/s1600/angularjs-first-basic-demo-for-beginners.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I am going to do following things in this demo.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add a Input field which updates a &#39;username&#39;&lt;/li&gt;
&lt;li&gt;Output the username property via String Interpolation&lt;/li&gt;
&lt;li&gt;Add a button which may only be clicked if the username is NOT an empty string&lt;/li&gt;
&lt;li&gt;Upon clicking the button, the username should be reset to an empty string&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here is the html code&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js &quot;&gt;&amp;lt;input 
  type=&quot;text&quot; 
  class=&quot;form-control&quot; 
  (input)=&quot;updateUserName($event)&quot;
  [(ngModel)]=&quot;uName&quot;
/&amp;gt;

&amp;lt;p&amp;gt;User Name is: {{ userName }}&amp;lt;/p&amp;gt;

&amp;lt;button class=&quot;btn btn-primary&quot;
[disabled]=&#39;!allowReset&#39;
(click)=&quot;resetUserName()&quot;&amp;gt;Reset&amp;lt;/button&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
And here is the&amp;nbsp;TypeScript file code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js &quot;&gt;import { Component, OnInit } from &#39;@angular/core&#39;;

@Component({
  selector: &#39;app-assignment&#39;,
  templateUrl: &#39;./assignment.component.html&#39;,
  styleUrls: [&#39;./assignment.component.css&#39;]
})
export class AssignmentComponent implements OnInit {
  allowReset = false;
  userName = &quot;&quot;;
  uName = &quot;&quot;;

  constructor() { }

  ngOnInit() {
  }

  updateUserName(event: Event){
    this.userName = (&amp;lt;HTMLInputElement&amp;gt;event.target).value;
    this.allowReset = true;

    if(this.userName == &quot;&quot;){
      this.allowReset = false;
    }
  }

  resetUserName(){
    this.userName = &quot;&quot;;
    this.uName = &quot;&quot;;
    this.allowReset = false;
  }

}
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/3822796632933109504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/12/angularjs-first-basic-demo-for-beginners.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3822796632933109504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3822796632933109504'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/12/angularjs-first-basic-demo-for-beginners.html' title='AngularJS First Basic Demo For Beginners'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW-wbdCdbtWR38SKJit3P-woJJwkWWFGKyhq1AoRC8IbUJnuOvS0GiFwl-iYv99pOzE26T16shXDM09GlGu6e9PpjulXp9K-j8p5XRpoiayJqG9paGuFYspMpgyGxBFNE8q3XxJs1xp1Q/s72-c/angularjs-first-basic-demo-for-beginners.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-7203793163192639090</id><published>2018-11-12T05:07:00.000-08:00</published><updated>2018-11-12T05:20:29.507-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Generate XML Language File For Android Using PHP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzOKteH51b8hLKc6syTTplhqPGaUBomUrECXKwWSc7HTG8LHFENQkq0izeexEM2u5DyIgYDq1UZa3XnUGHrEF75mQnhyphenhyphencRo8AvOyJoGmD431S8lsO8cMSF4Y2kA9cDLI313dyKF5HlKE8/s1600/generate-xml-language-file-for-android-2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;298&quot; data-original-width=&quot;810&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzOKteH51b8hLKc6syTTplhqPGaUBomUrECXKwWSc7HTG8LHFENQkq0izeexEM2u5DyIgYDq1UZa3XnUGHrEF75mQnhyphenhyphencRo8AvOyJoGmD431S8lsO8cMSF4Y2kA9cDLI313dyKF5HlKE8/s640/generate-xml-language-file-for-android-2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a common&amp;nbsp;headache for all android users to create xml file for multi languages app. Today i am sharing a simple PHP script that will generate xml language file for android app.&lt;br /&gt;
&lt;br /&gt;
To use this script you need to add all your keywords in a csv file like following image.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihw8kyt7hynnck9P-eIXtoUBdrow42r9LOsVhDKOZ5XVScM2TGwuwn8-gcGzfNfzdONN9Xs2aC1YFDeSCjwE8L3hvgDx-nLq2tY-6inUErhEqljuT955OU3zfDEjm4mCDvc87W1_OgHnA/s1600/generate-xml-language-file-for-android.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;187&quot; data-original-width=&quot;601&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihw8kyt7hynnck9P-eIXtoUBdrow42r9LOsVhDKOZ5XVScM2TGwuwn8-gcGzfNfzdONN9Xs2aC1YFDeSCjwE8L3hvgDx-nLq2tY-6inUErhEqljuT955OU3zfDEjm4mCDvc87W1_OgHnA/s1600/generate-xml-language-file-for-android.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Now create one php file, android.php and add following code&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

$filename = &quot;multi-language-android-en.csv&quot;;
$outputfileName = str_replace(&quot;.csv&quot;,&quot;.xml&quot;,$filename);
$file = fopen($filename, &#39;r&#39;);

$xml_file = $outputfileName;
if (file_exists($xml_file)) {
    unlink($xml_file);
}

//$xml_file = &quot;language.xml&quot;;
$doc = new DOMDocument(&#39;1.0&#39;, &#39;UTF-8&#39;);
$doc-&amp;gt;formatOutput = true;
$productsX = $doc-&amp;gt;createElement(&quot;resources&quot;);
$doc-&amp;gt;appendChild($productsX);

while (($line = fgetcsv($file)) !== FALSE) {
    //$line is an array of the csv elements
    //print_r($line);

    if (count($line) &amp;gt; 0) {

        $checktoskip = substr(trim($line[0]), 0, 2);

        if (trim($line[0]) == &quot;&quot; || $checktoskip == &quot;//&quot;) {
            $lan_xml = $doc-&amp;gt;createComment(&#39;Revised April 2008&#39;);
        }

        $lan_xml = $doc-&amp;gt;createElement(&quot;string&quot;);

        if (isset($line[0])) {
            $lan_xml-&amp;gt;setAttribute(&#39;name&#39;, trim($line[0]));
        }

        if (isset($line[1])) {
            $name = $doc-&amp;gt;createTextNode(trim($line[1]));
        }

        $lan_xml-&amp;gt;appendChild($name);

        $productsX-&amp;gt;appendChild($lan_xml);
    }
}

file_put_contents($xml_file, $doc-&amp;gt;saveXML(), FILE_APPEND);
echo &quot;Language xml generated successfully&quot;;

fclose($file);

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;In this php code &lt;b&gt;$filename = &quot;multi-language-android-en.csv&quot;&lt;/b&gt; is your csv file name.&lt;br /&gt;
&lt;br /&gt;
Once you&amp;nbsp;execute this code, it will create xml file like following image.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLgRjjxacZnOumBRwZ0WGti0Vgpt-q6189KybOmlfWjjz9qqqT559v2euXIl-xlgbejr0Qx-muToVVqVO0-Hcc5XUh48l2xvWntE8bD6C3mJLHEc9D77deeKRh4A98VmuonSd5gvnsQV0/s1600/generate-xml-language-file-for-android-1.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;207&quot; data-original-width=&quot;695&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLgRjjxacZnOumBRwZ0WGti0Vgpt-q6189KybOmlfWjjz9qqqT559v2euXIl-xlgbejr0Qx-muToVVqVO0-Hcc5XUh48l2xvWntE8bD6C3mJLHEc9D77deeKRh4A98VmuonSd5gvnsQV0/s1600/generate-xml-language-file-for-android-1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;https://www.dropbox.com/s/e0guhazqq4ivuok/HK_Android_XML.zip&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/7203793163192639090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/11/generate-xml-language-file-for-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7203793163192639090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7203793163192639090'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/11/generate-xml-language-file-for-android.html' title='Generate XML Language File For Android Using PHP'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzOKteH51b8hLKc6syTTplhqPGaUBomUrECXKwWSc7HTG8LHFENQkq0izeexEM2u5DyIgYDq1UZa3XnUGHrEF75mQnhyphenhyphencRo8AvOyJoGmD431S8lsO8cMSF4Y2kA9cDLI313dyKF5HlKE8/s72-c/generate-xml-language-file-for-android-2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-4296250888706215007</id><published>2018-10-02T03:15:00.000-07:00</published><updated>2018-10-02T03:15:07.701-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>Add Product Grid In Customer Admin Section And Save The Checkbox Values To Database - Magento 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In one of my project i want to add product grid in Magento 2 admin customer section with a separate tab. And also want to save selected product checkbox value to my custom database. After spending 2 days i found solution after merging few codes that i found.&lt;br /&gt;
&lt;br /&gt;
So i have created my custom magento 2 module that will do this all thing. It will add new tab in customer admin section and also save checkbox value to custom database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYQBgCBUx2QPbi7FZlCq3M95OFSllLRTtmIsOPh9yqvDiDcvUXkClMMR7mSam81KtxsbRWr5Y7CtVK5AhCm10hhzefNbDZwKttyLVKWnJJ-b1f97pt-IyjOEEw4J4BdU8Vors5hGx2NKU/s1600/add-product-grid-in-customer-admin-section.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Product Grid In Customer Admin Section&quot; border=&quot;0&quot; data-original-height=&quot;620&quot; data-original-width=&quot;1054&quot; height=&quot;376&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYQBgCBUx2QPbi7FZlCq3M95OFSllLRTtmIsOPh9yqvDiDcvUXkClMMR7mSam81KtxsbRWr5Y7CtVK5AhCm10hhzefNbDZwKttyLVKWnJJ-b1f97pt-IyjOEEw4J4BdU8Vors5hGx2NKU/s640/add-product-grid-in-customer-admin-section.png&quot; title=&quot;Product Grid In Customer Admin Section&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the quick steps to create module.&lt;br /&gt;
OR&lt;br /&gt;
You can download module here,&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Note: This module also include code to show selected product in front-end.
&lt;/span&gt;&lt;br /&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;https://www.dropbox.com/s/4nzysr796rvgdh3/M2-HK-Productattach.zip&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step1:&amp;nbsp;HK/Productattach/registration.php&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    &#39;HK_Productattach&#39;,
    __DIR__
);
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step2:&amp;nbsp;HK/Productattach/Block/Adminhtml/Edit/Tab/Products.php&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Block\Adminhtml\Edit\Tab;

use HK\Productattach\Model\ProductattachFactory;

class Products extends \Magento\Backend\Block\Widget\Grid\Extended
{
    /**
     * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
     */
    private $productCollectionFactory;

    //private $attachModel;

    /**
     * @var ProductattachFactory
     */
    private $contactFactory;

    /**
     * @var \Magento\Framework\Registry
     */
    private $registry;

    /**
     * Products constructor.
     * @param \Magento\Backend\Block\Template\Context $context
     * @param \Magento\Backend\Helper\Data $backendHelper
     * @param \Magento\Framework\Registry $registry
     * @param ProductattachFactory $contactFactory
     * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
     * @param array $data
     */
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Backend\Helper\Data $backendHelper,
        \Magento\Framework\Registry $registry,
        ProductattachFactory $contactFactory,
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
        array $data = []
    ) {
        $this-&amp;gt;contactFactory = $contactFactory;
        $this-&amp;gt;productCollectionFactory = $productCollectionFactory;
        $this-&amp;gt;registry = $registry;
        //$this-&amp;gt;attachModel = $attachModel;
        parent::__construct($context, $backendHelper, $data);
    }

    /**
     * _construct
     * @return void
     */
    public function _construct()
    {
        parent::_construct();
        $this-&amp;gt;setId(&#39;productsGrid&#39;);
        $this-&amp;gt;setDefaultSort(&#39;entity_id&#39;);
        $this-&amp;gt;setDefaultDir(&#39;DESC&#39;);
        $this-&amp;gt;setSaveParametersInSession(true);
        $this-&amp;gt;setUseAjax(true);
        if ($this-&amp;gt;getRequest()-&amp;gt;getParam(&#39;productattach_id&#39;)) {
        //if ($this-&amp;gt;getRequest()-&amp;gt;getParam(&#39;id&#39;)) {
            $this-&amp;gt;setDefaultFilter([&#39;in_product&#39; =&amp;gt; 1]);
        }
    }

    /**
     * @param \Magento\Backend\Block\Widget\Grid\Column $column
     * @return $this
     */
    public function _addColumnFilterToCollection($column)
    {
        if ($column-&amp;gt;getId() == &#39;in_product&#39;) {
            $productIds = $this-&amp;gt;_getSelectedProducts();

            if (empty($productIds)) {
                $productIds = 0;
            }
            if ($column-&amp;gt;getFilter()-&amp;gt;getValue()) {
                $this-&amp;gt;getCollection()-&amp;gt;addFieldToFilter(&#39;entity_id&#39;, [&#39;in&#39; =&amp;gt; $productIds]);
            } else {
                if ($productIds) {
                    $this-&amp;gt;getCollection()-&amp;gt;addFieldToFilter(&#39;entity_id&#39;, [&#39;nin&#39; =&amp;gt; $productIds]);
                }
            }
        } else {
            parent::_addColumnFilterToCollection($column);
        }

        return $this;
    }

    /**
     * prepare collection
     */
    public function _prepareCollection()
    {
        $collection = $this-&amp;gt;productCollectionFactory-&amp;gt;create();
        $collection-&amp;gt;addAttributeToSelect(&#39;name&#39;);
        $collection-&amp;gt;addAttributeToSelect(&#39;sku&#39;);
        $collection-&amp;gt;addAttributeToSelect(&#39;price&#39;);
        $this-&amp;gt;setCollection($collection);
        return parent::_prepareCollection();
    }

    /**
     * @return $this
     */
    public function _prepareColumns()
    {

        //$model = $this-&amp;gt;attachModel;

        $this-&amp;gt;addColumn(
            &#39;in_product&#39;,
            [
                &#39;header_css_class&#39; =&amp;gt; &#39;a-center&#39;,
                &#39;type&#39; =&amp;gt; &#39;checkbox&#39;,
                &#39;name&#39; =&amp;gt; &#39;in_product&#39;,
                &#39;align&#39; =&amp;gt; &#39;center&#39;,
                &#39;index&#39; =&amp;gt; &#39;entity_id&#39;,
                &#39;values&#39; =&amp;gt; $this-&amp;gt;_getSelectedProducts(),
            ]
        );

        $this-&amp;gt;addColumn(
            &#39;entity_id&#39;,
            [
                &#39;header&#39; =&amp;gt; __(&#39;Product ID&#39;),
                &#39;type&#39; =&amp;gt; &#39;number&#39;,
                &#39;index&#39; =&amp;gt; &#39;entity_id&#39;,
                &#39;header_css_class&#39; =&amp;gt; &#39;col-id&#39;,
                &#39;column_css_class&#39; =&amp;gt; &#39;col-id&#39;,
            ]
        );
        $this-&amp;gt;addColumn(
            &#39;names&#39;,
            [
                &#39;header&#39; =&amp;gt; __(&#39;Name&#39;),
                &#39;index&#39; =&amp;gt; &#39;name&#39;,
                &#39;class&#39; =&amp;gt; &#39;xxx&#39;,
                &#39;width&#39; =&amp;gt; &#39;50px&#39;,
            ]
        );
        $this-&amp;gt;addColumn(
            &#39;sku&#39;,
            [
                &#39;header&#39; =&amp;gt; __(&#39;Sku&#39;),
                &#39;index&#39; =&amp;gt; &#39;sku&#39;,
                &#39;class&#39; =&amp;gt; &#39;xxx&#39;,
                &#39;width&#39; =&amp;gt; &#39;50px&#39;,
            ]
        );
        $this-&amp;gt;addColumn(
            &#39;price&#39;,
            [
                &#39;header&#39; =&amp;gt; __(&#39;Price&#39;),
                &#39;type&#39; =&amp;gt; &#39;currency&#39;,
                &#39;index&#39; =&amp;gt; &#39;price&#39;,
                &#39;width&#39; =&amp;gt; &#39;50px&#39;,
            ]
        );

        return parent::_prepareColumns();
    }

    /**
     * @return string
     */
    public function getGridUrl()
    {
        return $this-&amp;gt;getUrl(&#39;*/*/productsgrid&#39;, [&#39;_current&#39; =&amp;gt; true]);
    }
    
    public function getTabUrl()
    {
        $id = 0;
        $customerId = $this-&amp;gt;getRequest()-&amp;gt;getParam(&#39;id&#39;);
        
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $hkproductCollection = $_objectManager-&amp;gt;create(&#39;HK\Productattach\Model\Productattach&#39;);
        $hkproductCollection = $hkproductCollection-&amp;gt;getCollection()-&amp;gt;addFieldToFilter(&#39;customer_id&#39;, $customerId);
        
        if($hkproductCollection-&amp;gt;count() &amp;gt; 0){
            $id = $hkproductCollection-&amp;gt;getFirstItem()-&amp;gt;getId();
        }
        
        return $this-&amp;gt;getUrl(&#39;productattach/*/products&#39;, [&#39;productattach_id&#39; =&amp;gt; $id, &#39;_current&#39; =&amp;gt; true]);
    }

    /**
     * @param  object $row
     * @return string
     */
    public function getRowUrl($row)
    {
        return &#39;&#39;;
    }

    public function _getSelectedProducts()
    {
        $contact = $this-&amp;gt;getContact();
        return $contact-&amp;gt;getProducts($contact);
    }

    /**
     * Retrieve selected products
     *
     * @return array
     */
    public function getSelectedProducts()
    {
        $contact = $this-&amp;gt;getContact();
        $selected = $contact-&amp;gt;getProducts($contact);
        
        if (!is_array($selected)) {
            $selected = [];
        }
        return $selected;
    }

    public function getContact()
    {
        $contactId = $this-&amp;gt;getRequest()-&amp;gt;getParam(&#39;productattach_id&#39;);
        $contact = $this-&amp;gt;contactFactory-&amp;gt;create();
        
        if ($contactId) {
            $contact-&amp;gt;load($contactId);
        }
        return $contact;
    }

    /**
     * {@inheritdoc}
     */
    public function canShowTab()
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function isHidden()
    {
        return true;
    }
    
    public function isAjaxLoaded()
    {
        return true;
    }
    
    public function getTabLabel()
    {
        return __(&#39;Customer Products&#39;);
    }

    /**
     * @return \Magento\Framework\Phrase
     */
    public function getTabTitle()
    {
        return __(&#39;Customer Products&#39;);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step3:&amp;nbsp;HK/Productattach/Controller/Adminhtml/Index/Products.php&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Controller\Adminhtml\Index;

use Magento\Backend\App\Action;

class Products extends \Magento\Backend\App\Action
{
    /**
     * @var \Magento\Framework\View\Result\LayoutFactory
     */
    private $resultLayoutFactory;

    /**
     * Products constructor.
     * @param Action\Context $context
     * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
     */
    public function __construct(
        Action\Context $context,
        \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
    ) {
        parent::__construct($context);
        $this-&amp;gt;resultLayoutFactory = $resultLayoutFactory;
    }

    /**
     * @return bool
     */
    public function _isAllowed()
    {
        return true;
    }

    /**
     * Save action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {

        $resultLayout = $this-&amp;gt;resultLayoutFactory-&amp;gt;create();
        $resultLayout-&amp;gt;getLayout()-&amp;gt;getBlock(&#39;productattach.edit.tab.products&#39;)
                     -&amp;gt;setInProducts($this-&amp;gt;getRequest()-&amp;gt;getPost(&#39;index_products&#39;, null));

        return $resultLayout;
    }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step4:&amp;nbsp;HK/Productattach/Controller/Adminhtml/Index/ProductsGrid.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Controller\Adminhtml\Index;

use Magento\Backend\App\Action;

class ProductsGrid extends \Magento\Backend\App\Action
{

    /**
     * @var \Magento\Framework\View\Result\LayoutFactory
     */
    private $resultLayoutFactory;

    /**
     * ProductsGrid constructor.
     * @param Action\Context $context
     * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
     */
    public function __construct(
        Action\Context $context,
        \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
    ) {
        parent::__construct($context);
        $this-&amp;gt;resultLayoutFactory = $resultLayoutFactory;
    }

    /**
     * @return bool
     */
    public function _isAllowed()
    {
        return true;
    }

    /**
     * Save action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        $resultLayout = $this-&amp;gt;resultLayoutFactory-&amp;gt;create();
        $resultLayout-&amp;gt;getLayout()-&amp;gt;getBlock(&#39;productattach.edit.tab.products&#39;)
                     -&amp;gt;setInBanner($this-&amp;gt;getRequest()-&amp;gt;getPost(&#39;index_products&#39;, null));

        return $resultLayout;
    }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step5:&amp;nbsp;HK/Productattach/etc/module.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd&quot;&amp;gt;
    &amp;lt;module name=&quot;HK_Productattach&quot; setup_version=&quot;1.0.2&quot;&amp;gt;
        &amp;lt;sequence&amp;gt;
            &amp;lt;module name=&quot;Magento_Backend&quot;/&amp;gt;
            &amp;lt;module name=&quot;Magento_Sales&quot;/&amp;gt;
            &amp;lt;module name=&quot;Magento_Quote&quot;/&amp;gt;
            &amp;lt;module name=&quot;Magento_Checkout&quot;/&amp;gt;
            &amp;lt;module name=&quot;Magento_Catalog&quot;/&amp;gt;
        &amp;lt;/sequence&amp;gt;
    &amp;lt;/module&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step6:&amp;nbsp;HK/Productattach/etc/adminhtml/routes.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App/etc/routes.xsd&quot;&amp;gt;
    &amp;lt;router id=&quot;admin&quot;&amp;gt;
        &amp;lt;route id=&quot;productattach&quot; frontName=&quot;productattach&quot;&amp;gt;
            &amp;lt;module name=&quot;HK_Productattach&quot; /&amp;gt;
        &amp;lt;/route&amp;gt;
    &amp;lt;/router&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step7:&amp;nbsp;HK/Productattach/etc/adminhtml/events.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Event/etc/events.xsd&quot;&amp;gt;
    &amp;lt;event name=&quot;adminhtml_customer_save_after&quot;&amp;gt;
        &amp;lt;observer name=&quot;customer_save_after&quot; instance=&quot;HK\Productattach\Observer\Customersaveafter&quot; /&amp;gt;
    &amp;lt;/event&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step8:&amp;nbsp;HK/Productattach/Model/Productattach.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
namespace HK\Productattach\Model;

class Productattach extends \Magento\Framework\Model\AbstractModel
{
    
    /**
     * Return unique ID(s) for each object in system
     *
     * @return array
     */
    public function getIdentities()
    {
        return [self::CACHE_TAG . &#39;_&#39; . $this-&amp;gt;getId()];
    }
    
    /**
     * Initialize resource model
     *
     * @return void
     */
    protected function _construct()
    {
        $this-&amp;gt;_init(&#39;HK\Productattach\Model\ResourceModel\Productattach&#39;);
    }
    
    public function getProducts(\HK\Productattach\Model\Productattach $object)
    {
        $id = $object-&amp;gt;getId();
        $tbl = $this-&amp;gt;getResource()-&amp;gt;getTable(&quot;hk_productattach&quot;);
        $select = $this-&amp;gt;getResource()-&amp;gt;getConnection()-&amp;gt;select()-&amp;gt;from(
            $tbl,
            [&#39;products&#39;]
        )
        -&amp;gt;where(
            &#39;productattach_id = ?&#39;,
            (int)$id
        );

        $products = $this-&amp;gt;getResource()-&amp;gt;getConnection()-&amp;gt;fetchCol($select);
        
        if ($products) {
            $products = explode(&#39;&amp;amp;&#39;, $products[0]);
        }

        return $products;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step9:&amp;nbsp;HK/Productattach/Model/ProductattachFactory.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Model;

class ProductattachFactory
{
    /**
     * @var \Magento\Framework\ObjectManagerInterface
     */
    protected $_objectManager;

    /**
     * @param \Magento\Framework\ObjectManagerInterface $objectManager
     */
    public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
    {
        $this-&amp;gt;_objectManager = $objectManager;
    }

    /**
     * Create new country model
     *
     * @param array $arguments
     * @return \Magento\Directory\Model\Country
     */
    public function create(array $arguments = [])
    {
        return $this-&amp;gt;_objectManager-&amp;gt;create(&#39;HK\Productattach\Model\Productattach&#39;, $arguments, false);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step10:&amp;nbsp;HK/Productattach/Model/ResourceModel/Productattach.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
namespace HK\Productattach\Model\ResourceModel;

class Productattach extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    /**
     * Initialize resource model
     *
     * @return void
     */
    protected function _construct()
    {
        $this-&amp;gt;_init(&#39;hk_productattach&#39;, &#39;productattach_id&#39;);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step11:&amp;nbsp;HK/Productattach/Model/ResourceModel/Productattach/Collection.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Model\ResourceModel\Productattach;

class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{

    /**
     * Define resource model
     *
     * @return void
     */
    protected function _construct()
    {
        $this-&amp;gt;_init(&#39;HK\Productattach\Model\Productattach&#39;, &#39;HK\Productattach\Model\ResourceModel\Productattach&#39;);
        //$this-&amp;gt;_map[&#39;fields&#39;][&#39;page_id&#39;] = &#39;main_table.page_id&#39;;
    }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step12:&amp;nbsp;HK/Productattach/Observer/Customersaveafter.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Observer;

use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;

class Customersaveafter implements ObserverInterface {

    protected $objectManager;

    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager
    ) {
        $this-&amp;gt;objectManager = $objectManager;
    }

    public function execute(EventObserver $observer) {

        $customer = $observer-&amp;gt;getEvent()-&amp;gt;getData(&#39;customer&#39;);
        $products = $observer-&amp;gt;getRequest()-&amp;gt;getPost(&#39;products&#39;);
        
  $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $hkproductModel = $this-&amp;gt;objectManager-&amp;gt;create(&#39;HK\Productattach\Model\Productattach&#39;);
  $hkproductCollection = $hkproductModel-&amp;gt;getCollection()-&amp;gt;addFieldToFilter(&#39;customer_id&#39;, $customer-&amp;gt;getId());
  
  if($hkproductCollection-&amp;gt;count() &amp;gt; 0){
   $hkproductCollection = $hkproductCollection-&amp;gt;getFirstItem();
   $hkproductCollection-&amp;gt;setProducts($products);
   $hkproductCollection-&amp;gt;save();
  }else{
   if($products){
    $hkproductModel-&amp;gt;setData(array(&#39;products&#39;=&amp;gt;$products, &#39;customer_id&#39; =&amp;gt; $customer-&amp;gt;getId()));
    $hkproductModel-&amp;gt;save();
   }
  }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step13:&amp;nbsp;HK/Productattach/Setup/InstallSchema.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Productattach\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\DB\Adapter\AdapterInterface;

class InstallSchema implements InstallSchemaInterface {

    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) {
        $installer = $setup;

        $installer-&amp;gt;startSetup();
        
  $installer-&amp;gt;getConnection()-&amp;gt;dropTable($installer-&amp;gt;getTable(&#39;hk_productattach&#39;));

  $hk_productattach = $installer-&amp;gt;getConnection()-&amp;gt;newTable($installer-&amp;gt;getTable(&#39;hk_productattach&#39;));

  $hk_productattach-&amp;gt;addColumn(
   &#39;productattach_id&#39;,
   \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
   null,
   [&#39;identity&#39; =&amp;gt; true, &#39;unsigned&#39; =&amp;gt; true, &#39;nullable&#39; =&amp;gt; false, &#39;primary&#39; =&amp;gt; true],
   &#39;Entity Id&#39;
  );

  $hk_productattach-&amp;gt;addColumn(
   &#39;customer_id&#39;,
   \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
   null,
   [&#39;nullable&#39; =&amp;gt; true,&#39;default&#39; =&amp;gt; null],
   &#39;Customer ID&#39;
  );

  $hk_productattach-&amp;gt;addColumn(
   &#39;products&#39;,
   \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
   null,
   [&#39;nullable&#39; =&amp;gt; true,&#39;default&#39; =&amp;gt; null],
   &#39;Assigned Products&#39;
  );

  $hk_productattach-&amp;gt;addColumn(
   &#39;created_at&#39;,
   \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
   null,
   [&#39;nullable&#39; =&amp;gt; false],
   &#39;Created At&#39;
  );

  $installer-&amp;gt;getConnection()-&amp;gt;createTable($hk_productattach);
  $installer-&amp;gt;endSetup();
  
        $installer-&amp;gt;endSetup();
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step14:&amp;nbsp;HK/Productattach/view/adminhtml/layout/customer_index_edit.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;page xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; layout=&quot;admin-2columns-left&quot;
      xsi:noNamespaceSchemaLocation=&quot;../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd&quot;&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;referenceBlock name=&quot;customer_form&quot;&amp;gt;
            &amp;lt;block class=&quot;HK\Productattach\Block\Adminhtml\Edit\Tab\Products&quot; name=&quot;customer_edit_tab_products&quot;&amp;gt;
                &amp;lt;action method=&quot;setTabLabel&quot;&amp;gt;
                    &amp;lt;argument name=&quot;label&quot; xsi:type=&quot;string&quot;&amp;gt;Customer Products&amp;lt;/argument&amp;gt;
                &amp;lt;/action&amp;gt;
            &amp;lt;/block&amp;gt;
        &amp;lt;/referenceBlock&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/page&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step15:&amp;nbsp;HK/Productattach/view/adminhtml/layout/productattach_index_products.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;layout xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/layout_generic.xsd&quot;&amp;gt;
    &amp;lt;container name=&quot;root&quot; label=&quot;Root&quot;&amp;gt;
        &amp;lt;block class=&quot;HK\Productattach\Block\Adminhtml\Edit\Tab\Products&quot; name=&quot;productattach.edit.tab.products&quot;/&amp;gt;
        &amp;lt;block class=&quot;Magento\Backend\Block\Widget\Grid\Serializer&quot; name=&quot;products_grid_serializer&quot;&amp;gt;
            &amp;lt;arguments&amp;gt;
                &amp;lt;argument name=&quot;grid_block&quot; xsi:type=&quot;string&quot;&amp;gt;productattach.edit.tab.products&amp;lt;/argument&amp;gt;
                &amp;lt;argument name=&quot;callback&quot; xsi:type=&quot;string&quot;&amp;gt;getSelectedProducts&amp;lt;/argument&amp;gt;
                &amp;lt;argument name=&quot;input_element_name&quot; xsi:type=&quot;string&quot;&amp;gt;products&amp;lt;/argument&amp;gt;
                &amp;lt;argument name=&quot;reload_param_name&quot; xsi:type=&quot;string&quot;&amp;gt;index_products&amp;lt;/argument&amp;gt;
            &amp;lt;/arguments&amp;gt;
        &amp;lt;/block&amp;gt;
        &amp;lt;block class=&quot;Magento\Framework\View\Element\Template&quot; name=&quot;grid_scriptjs&quot; template=&quot;HK_Productattach::scriptjs.phtml&quot;/&amp;gt;
    &amp;lt;/container&amp;gt;
&amp;lt;/layout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step16:&amp;nbsp;HK/Productattach/view/adminhtml/layout/productattach_index_productsgrid.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;layout xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View/Layout/etc/layout_generic.xsd&quot;&amp;gt;
    &amp;lt;container name=&quot;root&quot; label=&quot;Root&quot;&amp;gt;
        &amp;lt;block class=&quot;HK\Productattach\Block\Adminhtml\Edit\Tab\Products&quot; name=&quot;productattach.edit.tab.products&quot;/&amp;gt;
    &amp;lt;/container&amp;gt;
&amp;lt;/layout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step17:&amp;nbsp;HK/Productattach/view/adminhtml/templates/scriptjs.phtml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-javascript&quot;&gt;&amp;lt;script&amp;gt;
    require([
        &quot;jquery&quot;,

    ], function($){     
        $(&quot;input[name=&#39;products&#39;]&quot;).attr(&#39;data-form-part&#39;,&#39;customer_form&#39;);      
    });
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
Now run following commands and you are done.
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
&lt;/pre&gt;
&lt;br /&gt;
I hope this will help someone. &lt;br /&gt;
Thanks&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/4296250888706215007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/10/add-product-grid-in-customer-admin-section.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4296250888706215007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4296250888706215007'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/10/add-product-grid-in-customer-admin-section.html' title='Add Product Grid In Customer Admin Section And Save The Checkbox Values To Database - Magento 2'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYQBgCBUx2QPbi7FZlCq3M95OFSllLRTtmIsOPh9yqvDiDcvUXkClMMR7mSam81KtxsbRWr5Y7CtVK5AhCm10hhzefNbDZwKttyLVKWnJJ-b1f97pt-IyjOEEw4J4BdU8Vors5hGx2NKU/s72-c/add-product-grid-in-customer-admin-section.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-2448876425325700788</id><published>2018-05-26T05:20:00.000-07:00</published><updated>2018-05-26T05:20:28.112-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><category scheme="http://www.blogger.com/atom/ns#" term="php file upload"/><title type='text'>Magento2 Upload files using mediastorage module and ajax</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;How to upload files using magento2 mediastorage module in amin&lt;/b&gt; – Want to upload files in magento2 then no need to worry about file upload functions, here you will find the method to upload files using magento2 mediastorage module and ajax.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSs4vxtQnY-OdcsQJ4mE55ubQ47vX9D2-1svUQbSChRfnuey6-YspYNT48_F-u75fihA7avFwAjqqn5REvdvKKE3uBh8wGQMAaDYt7fDHlzOfjiNB_aXJfcvQy126myi3STCmX977usJ0/s1600/magento2-upload-files.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;352&quot; data-original-width=&quot;630&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSs4vxtQnY-OdcsQJ4mE55ubQ47vX9D2-1svUQbSChRfnuey6-YspYNT48_F-u75fihA7avFwAjqqn5REvdvKKE3uBh8wGQMAaDYt7fDHlzOfjiNB_aXJfcvQy126myi3STCmX977usJ0/s1600/magento2-upload-files.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
For this you just need to follow these easy steps and your file will be uploaded to custom directory with proper validations.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step1: Add following code in your phtml file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;div class=&quot;form_parent&quot;&amp;gt;
 &amp;lt;form class=&quot;form&quot; method=&quot;post&quot; id=&quot;frm_attachment&quot; enctype=&quot;multipart/form-data&quot; autocomplete=&quot;off&quot;&amp;gt;
  &amp;lt;div class=&quot;admin__field field field-email&quot;&amp;gt;
   &amp;lt;label class=&quot;label admin__field-label&quot;&amp;gt;&amp;lt;span&amp;gt;Attachment&amp;lt;/span&amp;gt;&amp;lt;/label&amp;gt;
   &amp;lt;div class=&quot;admin__field-control control&quot;&amp;gt;
    &amp;lt;button type=&quot;button&quot; class=&quot;scalable action-show-hide&quot; id=&quot;uploadAttachment&quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;span&amp;gt;Upload&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;
    &amp;lt;input type=&quot;file&quot; id=&quot;attachment&quot; name=&quot;attachment&quot; style=&quot;display: none;&quot;/&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
 &amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div id=&quot;attachmentFiles&quot;&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
    require([&#39;jquery&#39;], function ($) {
        $(document).ready(function ($) {
            
            $(document).on(&#39;click&#39;, &#39;#attachmentFiles .action-remove&#39;, function(){
               if (window.confirm(&quot;Are you sure you want to delete?&quot;)) {
                   var attachmentPath = $(this).attr(&quot;data-image&quot;);
                   var divID = $(this).parents(&quot;.base-image&quot;).attr(&quot;id&quot;);
                   var imageID = $(this).parents(&quot;.base-image&quot;).find(&quot;.hiddneattachID&quot;).val();
                   
                   jQuery.ajax({
                        url: &quot;&amp;lt;?php echo $block-&amp;gt;getBaseUrl() . &#39;admin/hk/attachment/deleteAttachment?isAjax=true&#39; ?&amp;gt;&quot;,
                        type: &quot;POST&quot;,
                        data: {filename: attachmentPath, form_key: window.FORM_KEY, imageID:imageID},
                        showLoader: true,
                        success: function (response) {
                            if(response.success == true){
                                $(&quot;.base-image#&quot;+divID).remove();
                            }
                            alert(response.message);
                        },
                       error: function (response) {
                            alert(response.message);
                       }
                    });
               } 
            });
            
            $(&#39;#uploadAttachment&#39;).click(function(){ $(&#39;#attachment&#39;).trigger(&#39;click&#39;); });
            
            $(&quot;#attachment&quot;).change(function(){
                var data = $(&quot;#frm_attachment&quot;).get(0);
                
                jQuery.ajax({
                     url: &quot;&amp;lt;?php echo $block-&amp;gt;getBaseUrl() . &#39;admin/hk/attachment/addAttachment?isAjax=true&#39; ?&amp;gt;&quot;,
                     type: &quot;POST&quot;,
                     data: new FormData(data),
                     processData: false,
                     contentType: false,
                     showLoader: true,
                     success: function (response) {
                         alert(response.message);
                         $(&quot;#attachmentFiles&quot;).append(response.data.html);
                         $(&#39;#frm_attachment&#39;)[0].reset();
                     },
                    error: function (response) {
                         alert(response.message);
                         $(&#39;#frm_attachment&#39;)[0].reset();
                    }
                 });
            });
        });
    });
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step2: Create&amp;nbsp;AddAttachment.php file to upload your file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Attachment\Controller\Adminhtml\Action;

use Magento\Framework\Json\Helper\Data as JsonHelper;

class AddAttachment extends \Magento\Backend\App\Action {
    
    protected $_mediaDirectory;
    protected $_fileUploaderFactory;
    public $_storeManager;

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        JsonHelper $jsonHelper,
        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
        \Magento\Framework\Filesystem $filesystem,
        \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
        \Magento\Store\Model\StoreManagerInterface $storeManager
    ) {
        parent::__construct($context);
        $this-&amp;gt;jsonHelper = $jsonHelper;
        $this-&amp;gt;resultJsonFactory = $resultJsonFactory;
        $this-&amp;gt;_mediaDirectory = $filesystem-&amp;gt;getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
        $this-&amp;gt;_fileUploaderFactory = $fileUploaderFactory;
        $this-&amp;gt;_storeManager = $storeManager;
    }

    
    public function execute(){
        
        $_postData = $this-&amp;gt;getRequest()-&amp;gt;getPost();
        
        $message = &quot;&quot;;
        $newFileName = &quot;&quot;;
        $error = false;
        $data = array();
        
        try{
            $target = $this-&amp;gt;_mediaDirectory-&amp;gt;getAbsolutePath(&#39;leads/&#39;);        
            
   //attachment is the input file name posted from your form
            $uploader = $this-&amp;gt;_fileUploaderFactory-&amp;gt;create([&#39;fileId&#39; =&amp;gt; &#39;attachment&#39;]);
            
            //$_fileType = $uploader-&amp;gt;getFileExtension();
            $newFileName = uniqid().&#39;.&#39;.$_fileType;
            
            /** Allowed extension types */
            $uploader-&amp;gt;setAllowedExtensions([&#39;jpg&#39;, &#39;jpeg&#39;, &#39;gif&#39;, &#39;png&#39;, &#39;pdf&#39;, &#39;doc&#39;, &#39;docx&#39;, &#39;xls&#39;, &#39;xlsx&#39;, &#39;csv&#39;]);
            /** rename file name if already exists */
            $uploader-&amp;gt;setAllowRenameFiles(true);
            
            $result = $uploader-&amp;gt;save($target, $newFileName); //Use this if you want to change your file name
   //$result = $uploader-&amp;gt;save($target);
            if ($result[&#39;file&#39;]) {
                
                $_mediaUrl = $this-&amp;gt;_storeManager-&amp;gt;getStore()-&amp;gt;getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
                $_iconArray = array(
                    &#39;pdf&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-pdf.png&#39;,
                    &#39;doc&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-doc.png&#39;,
                    &#39;docx&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-docx.png&#39;,
                    &#39;xls&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-xls.png&#39;,
                    &#39;xlsx&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-xlsx.png&#39;,
                    &#39;csv&#39; =&amp;gt; $_mediaUrl.&#39;leads/default/icon-csv.png&#39;,
                );
                
                if(isset($_iconArray[$_fileType])){
                    $_src = $_iconArray[$_fileType];
                }else{
                    $_src = $_mediaUrl.&#39;leads/&#39;.$newFileName;
                }
                
                $error = false;
                $message = &quot;File has been successfully uploaded&quot;;
                
                $html = &#39;&amp;lt;div class=&quot;image item base-image&quot; data-role=&quot;image&quot; id=&quot;&#39;. uniqid().&#39;&quot;&amp;gt;
                            &amp;lt;div class=&quot;product-image-wrapper&quot;&amp;gt;
                                &amp;lt;img class=&quot;product-image&quot; data-role=&quot;image-element&quot; src=&quot;&#39;.$_src.&#39;&quot; alt=&quot;&quot;&amp;gt;
                                &amp;lt;div class=&quot;actions&quot;&amp;gt;
                                    &amp;lt;button type=&quot;button&quot; class=&quot;action-remove&quot; data-role=&quot;delete-button&quot; data-image=&quot;&#39;.$newFileName.&#39;&quot; title=&quot;Delete image&quot;&amp;gt;&amp;lt;span&amp;gt;Delete image&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;
                                &amp;lt;/div&amp;gt;
                                &amp;lt;div class=&quot;image-fade&quot;&amp;gt;&amp;lt;span&amp;gt;Hidden&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;
                            &amp;lt;/div&amp;gt;
                            &amp;lt;div class=&quot;item-description&quot;&amp;gt;
                                &amp;lt;div class=&quot;item-title&quot; data-role=&quot;img-title&quot;&amp;gt;&amp;lt;/div&amp;gt;
                                &amp;lt;div class=&quot;item-size&quot;&amp;gt;
                                    &amp;lt;a href=&quot;&#39;.$_mediaUrl.&#39;leads/&#39;.$newFileName.&#39;&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;span data-role=&quot;image-dimens&quot;&amp;gt;&#39;.$newFileName.&#39;&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;
                                &amp;lt;/div&amp;gt;
                            &amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;&#39;;
                
                $data = array(&#39;filename&#39; =&amp;gt; $newFileName, &#39;path&#39; =&amp;gt; $_mediaUrl.&#39;leads/&#39;.$newFileName, &#39;fileType&#39; =&amp;gt; $_fileType, &#39;html&#39; =&amp;gt; $html);
            }
        } catch (\Exception $e) {
            $error = true;
            $message = $e-&amp;gt;getMessage();
        }
        
        $resultJson = $this-&amp;gt;resultJsonFactory-&amp;gt;create();

        return $resultJson-&amp;gt;setData([
                    &#39;message&#39; =&amp;gt; $message,
                    &#39;data&#39; =&amp;gt; $data,
                    &#39;error&#39; =&amp;gt; $error
        ]);
    }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step3: Create&amp;nbsp;DeleteAttachment.php file to delete your file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

namespace HK\Attachment\Controller\Adminhtml\Action;

use Magento\Framework\Json\Helper\Data as JsonHelper;

class DeleteAttachment extends \Magento\Backend\App\Action {
    
    protected $_mediaDirectory;
    protected $_fileUploaderFactory;
    public $_storeManager;
    protected $_file;

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        JsonHelper $jsonHelper,
        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
        \Magento\Framework\Filesystem $filesystem,
        \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\Filesystem\Driver\File $file
    ) {
        parent::__construct($context);
        $this-&amp;gt;jsonHelper = $jsonHelper;
        $this-&amp;gt;resultJsonFactory = $resultJsonFactory;
        $this-&amp;gt;_mediaDirectory = $filesystem-&amp;gt;getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
        $this-&amp;gt;_fileUploaderFactory = $fileUploaderFactory;
        $this-&amp;gt;_storeManager = $storeManager;
        $this-&amp;gt;_file = $file;
    }

    
    public function execute(){
        
        $_postData = $this-&amp;gt;getRequest()-&amp;gt;getPost();
        
        $message = &quot;&quot;;
        $newFileName = &quot;&quot;;
        $success = false;
        
        $mediaRootDir = $this-&amp;gt;_mediaDirectory-&amp;gt;getAbsolutePath();
        $_fileName = $mediaRootDir .&#39;leads/&#39;. $_postData[&#39;filename&#39;];
        if ($this-&amp;gt;_file-&amp;gt;isExists($_fileName))  {
            try{
                $this-&amp;gt;attachment-&amp;gt;load($_postData[&#39;imageID&#39;]);
                $this-&amp;gt;attachment-&amp;gt;delete();
                
                $this-&amp;gt;_file-&amp;gt;deleteFile($_fileName);
                $message = &quot;File removed successfully.&quot;;
                $success = true;
            } catch (Exception $ex) {
                $message = $e-&amp;gt;getMessage();
                $success = false;
            }
        }else{
            $message = &quot;File not found.&quot;;
            $success = false;
        }
        
        $resultJson = $this-&amp;gt;resultJsonFactory-&amp;gt;create();

        return $resultJson-&amp;gt;setData([
                    &#39;message&#39; =&amp;gt; $message,
                    &#39;data&#39; =&amp;gt; &#39;&#39;,
                    &#39;success&#39; =&amp;gt; $success
        ]);         
    }
}

&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/2448876425325700788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/05/magento2-upload-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/2448876425325700788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/2448876425325700788'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/05/magento2-upload-files.html' title='Magento2 Upload files using mediastorage module and ajax'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSs4vxtQnY-OdcsQJ4mE55ubQ47vX9D2-1svUQbSChRfnuey6-YspYNT48_F-u75fihA7avFwAjqqn5REvdvKKE3uBh8wGQMAaDYt7fDHlzOfjiNB_aXJfcvQy126myi3STCmX977usJ0/s72-c/magento2-upload-files.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-4297349386379096990</id><published>2018-01-26T03:51:00.000-08:00</published><updated>2018-01-26T22:00:27.832-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><category scheme="http://www.blogger.com/atom/ns#" term="php csv script"/><title type='text'>Magento 2 Add Product Review And Rating Programatically</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post i am going to explain that how to create product review and rating programatically from csv file in Magento 2.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtXPnuEftSuIqFfWFljQpOD1i36p5nIhCuK89rZ2ouNFBKG3Lj3R0AVlbjeguhpyHDB-96HW6QnKZ92zAQ3ZkFklz1hzZBG4w4zc0MjNQjt9-usDL03eYFZsmsIoqWGG4U6hyphenhyphensahyphenhyphenqEmU/s1600/magento-2-add-product-review-and-rating.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Magento 2 Add Product Review And Rating Programatically&quot; border=&quot;0&quot; data-original-height=&quot;272&quot; data-original-width=&quot;573&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtXPnuEftSuIqFfWFljQpOD1i36p5nIhCuK89rZ2ouNFBKG3Lj3R0AVlbjeguhpyHDB-96HW6QnKZ92zAQ3ZkFklz1hzZBG4w4zc0MjNQjt9-usDL03eYFZsmsIoqWGG4U6hyphenhyphensahyphenhyphenqEmU/s1600/magento-2-add-product-review-and-rating.png&quot; title=&quot;Magento 2 Add Product Review And Rating Programatically&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Create import_review.php file in root of your magento and add following code.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php

use Magento\Framework\App\Bootstrap;

require __DIR__ . &#39;/app/bootstrap.php&#39;;
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap-&amp;gt;getObjectManager();
$state = $obj-&amp;gt;get(&#39;Magento\Framework\App\State&#39;);
$state-&amp;gt;setAreaCode(&#39;frontend&#39;);

ini_set(&#39;display_errors&#39;, 1);

$file = fopen(&#39;products_review.csv&#39;, &#39;r&#39;);


$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$reviewFactory = $objectManager-&amp;gt;get(&quot;Magento\Review\Model\ReviewFactory&quot;);
$ratingFactory = $objectManager-&amp;gt;get(&quot;Magento\Review\Model\RatingFactory&quot;);
$storeManager = $objectManager-&amp;gt;get(&quot;Magento\Store\Model\StoreManagerInterface&quot;);

$i = 0;
while (($line = fgetcsv($file)) !== FALSE) {
    if (count($line) &amp;gt; 0) {

        $sku = $line[0];
        $review_rating = $line[1];
        $reviewTitle = $line[2];
        $reviewDetail = $line[3];
        $UserEmail = $line[4];
        $customerId = 0;

        if ($i &amp;gt; 0) {
            $productId = $objectManager-&amp;gt;get(&#39;Magento\Catalog\Model\Product&#39;)-&amp;gt;getIdBySku($sku);

            if ($productId) {
                $reviewFinalData = array();
                $reviewFinalData[&#39;ratings&#39;][1] = $review_rating;
                $reviewFinalData[&#39;ratings&#39;][2] = $review_rating;
                $reviewFinalData[&#39;ratings&#39;][3] = $review_rating;

                $reviewFinalData[&#39;nickname&#39;] = &quot;Guest&quot;;

                if ($UserEmail) {
                    $websiteId = $storeManager-&amp;gt;getWebsite()-&amp;gt;getWebsiteId();
                    $customerFactory = $objectManager-&amp;gt;get(&#39;\Magento\Customer\Model\CustomerFactory&#39;);
                    $customer = $customerFactory-&amp;gt;create();
                    $customer-&amp;gt;setWebsiteId($websiteId);
                    $customer-&amp;gt;loadByEmail($UserEmail);
                    $data = $customer-&amp;gt;getData();
                    $customerId = $data[&#39;entity_id&#39;];
                    $firstname = $data[&#39;firstname&#39;];
                    $lastname = ($data[&#39;lastname&#39;] ? &quot; &quot; . $data[&#39;lastname&#39;] : &quot;&quot;);
                    $reviewFinalData[&#39;nickname&#39;] = $firstname . $lastname;
                }

                $reviewFinalData[&#39;title&#39;] = $reviewTitle;
                $reviewFinalData[&#39;detail&#39;] = $reviewDetail;

                $review = $reviewFactory-&amp;gt;create()-&amp;gt;setData($reviewFinalData);

                $review-&amp;gt;unsetData(&#39;review_id&#39;);

                $review-&amp;gt;setEntityId($review-&amp;gt;getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE))
                        -&amp;gt;setEntityPkValue($productId)
                        -&amp;gt;setStatusId(\Magento\Review\Model\Review::STATUS_APPROVED)//By default set approved
                        -&amp;gt;setStoreId($storeManager-&amp;gt;getStore()-&amp;gt;getId())
                        -&amp;gt;setStores([$storeManager-&amp;gt;getStore()-&amp;gt;getId()]);

                if ($customerId) {
                    $review-&amp;gt;setCustomerId($customerId);
                }

                $review-&amp;gt;save();

                foreach ($reviewFinalData[&#39;ratings&#39;] as $ratingId =&amp;gt; $optionId) {
                    $ratingFactory-&amp;gt;create()
                            -&amp;gt;setRatingId($ratingId)
                            -&amp;gt;setReviewId($review-&amp;gt;getId())
                            -&amp;gt;addOptionVote($optionId, $productId);
                }

                $review-&amp;gt;aggregate();
            }
        }
    }
    $i++;
}
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
You can download sample csv file and script from following link&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;http://goo.gl/djXdmr&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/4297349386379096990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/01/magento-2-add-product-review-and-rating.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4297349386379096990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4297349386379096990'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/01/magento-2-add-product-review-and-rating.html' title='Magento 2 Add Product Review And Rating Programatically'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtXPnuEftSuIqFfWFljQpOD1i36p5nIhCuK89rZ2ouNFBKG3Lj3R0AVlbjeguhpyHDB-96HW6QnKZ92zAQ3ZkFklz1hzZBG4w4zc0MjNQjt9-usDL03eYFZsmsIoqWGG4U6hyphenhyphensahyphenhyphenqEmU/s72-c/magento-2-add-product-review-and-rating.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-4229534432202669862</id><published>2018-01-06T05:08:00.000-08:00</published><updated>2018-01-09T23:53:32.983-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CRUD"/><category scheme="http://www.blogger.com/atom/ns#" term="Express"/><category scheme="http://www.blogger.com/atom/ns#" term="MongoDB"/><category scheme="http://www.blogger.com/atom/ns#" term="node"/><category scheme="http://www.blogger.com/atom/ns#" term="nodejs"/><title type='text'>Basic Simple CRUD Application with Express and MongoDB</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post i have created a basic simple application using &lt;b&gt;Express&lt;/b&gt; and &lt;b&gt;MongoDB&lt;/b&gt;&amp;nbsp;to Create, Read, Update and Delete data in MongoDB.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2dtLzVwB-7oXjkT2rnRTfV5pt2ApeW-LWPJGFPhMwTW28VqzBe_lLRcbLNF2sblYelCBo13kvOY5q75n8m6fbPK-pAjssqnRafF1Izl_yAczYcMQpT63YJ0BYxHz2JAzj5K9_hf1D9cU/s1600/crud-express-mongodb.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Crud-express-mongodb&quot; border=&quot;0&quot; data-original-height=&quot;720&quot; data-original-width=&quot;1280&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2dtLzVwB-7oXjkT2rnRTfV5pt2ApeW-LWPJGFPhMwTW28VqzBe_lLRcbLNF2sblYelCBo13kvOY5q75n8m6fbPK-pAjssqnRafF1Izl_yAczYcMQpT63YJ0BYxHz2JAzj5K9_hf1D9cU/s640/crud-express-mongodb.jpg&quot; title=&quot;Crud-express-mongodb&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
To use this application you need to install &lt;b&gt;&lt;a href=&quot;https://nodejs.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Node.js&lt;/a&gt;&lt;/b&gt; and also have some basic knowledge of typing commands.&lt;br /&gt;
&lt;br /&gt;
To check if you have Node installed, open up your command line and run the following code:&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js&quot;&gt;node -v&lt;/pre&gt;
&lt;br /&gt;
In this example we are going to store databases on cloud &lt;span id=&quot;goog_1202090688&quot;&gt;&lt;/span&gt;like &lt;a href=&quot;https://mlab.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;mlab.com&lt;/a&gt;. So you need to create your database before starting this.&amp;nbsp;&lt;span id=&quot;goog_1202090689&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now let&#39;s create required files step by step:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step1:&lt;/b&gt; Create &lt;b&gt;server.js&lt;/b&gt; file and add following code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js&quot;&gt;const express = require(&#39;express&#39;);
const app = express();
const bodyParser = require(&#39;body-parser&#39;);
const MongoClient = require(&#39;mongodb&#39;).MongoClient;

/////Body parser
app.use(bodyParser.urlencoded({extended: true}))
//app.use(bodyParser.json());
app.use(express.static(&#39;public&#39;));
app.set(&#39;view engine&#39;, &#39;ejs&#39;)


/////MongoDB
var db;
var ObjectId = require(&#39;mongodb&#39;).ObjectID;

MongoClient.connect(&#39;your_mongodb_url&#39;, (err, database) =&amp;gt; {
    if (err) {
        throw err;
    }

    db = database.db(&#39;db_name&#39;)
    db.collection(&#39;customer&#39;)
    app.listen(3000, () =&amp;gt; {
        console.log(&#39;database connected listening on 3000&#39;);
    })
})

app.get(&#39;/&#39;, (req, res) =&amp;gt; {
    db.collection(&#39;customer&#39;).find().toArray((err, result) =&amp;gt; {
        if (err) {
            throw err;
        }
        res.render(&#39;index.ejs&#39;, {data: result})
    })
})

app.post(&#39;/addnew&#39;, (req, res) =&amp;gt; {

    var myobj = {name: req.body.name, address: req.body.address};
    db.collection(&quot;customer&quot;).insertOne(myobj, function (err, result) {
        if (err) {
            throw err;
        }
        console.log(&quot;1 record inserted&quot;);
        res.redirect(&#39;/&#39;)
    });
})


////////////////////Update
app.get(&#39;/update/:id&#39;, (req, res) =&amp;gt; {
    var user_id = req.params.id;
    console.log(user_id);
    var query = {_id: ObjectId(user_id)};
    db.collection(&quot;customer&quot;).find(query).toArray(function (err, result) {
        if (err) {
            throw err;
        }
        console.log(result);
        res.render(&#39;update.ejs&#39;, {data: result})
    });
})

app.post(&#39;/updatepost&#39;, (req, res) =&amp;gt; {
    var myquery = {_id: ObjectId(req.body.id)};
    //var newvalues = {name: req.body.name, address: req.body.quote};
    var newvalues = {$set: {name: req.body.name, address: req.body.address}};
    var extra = {upsert: true};
    db.collection(&quot;customer&quot;).updateOne(myquery, newvalues, extra, function (err, result) {
        if (err) {
            throw err;
        }
        console.log(&quot;1 record updated&quot;);
        res.redirect(&#39;/&#39;)
    });
})


/////////////////Delete
app.get(&#39;/delete/:id&#39;, (req, res) =&amp;gt; {
    var user_id = req.params.id;
    console.log(user_id);
    var query = {_id: ObjectId(user_id)};
    db.collection(&quot;customer&quot;).deleteOne(query, function (err, obj) {
        if (err) {
            throw err;
        }
        console.log(&quot;1 record deleted&quot;);
        res.redirect(&#39;/&#39;)
    });
})
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; Replace &#39;your_mongodb_url&#39; with your mongodb url and &#39;db_name&#39; with the database name.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step2:&lt;/b&gt; Create &lt;b&gt;package.json&lt;/b&gt; file and add following code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-js&quot;&gt;{
  &quot;name&quot;: &quot;node&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;server.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;amp;&amp;amp; exit 1&quot;,
    &quot;start&quot;: &quot;node server.js&quot;,
    &quot;dev&quot;: &quot;nodemon server.js&quot;
  },
  &quot;author&quot;: &quot;Hardik Patel&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;dependencies&quot;: {
    &quot;body-parser&quot;: &quot;^1.18.2&quot;,
    &quot;ejs&quot;: &quot;^2.5.7&quot;,
    &quot;express&quot;: &quot;^4.16.2&quot;,
    &quot;mongodb&quot;: &quot;^3.0.1&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;nodemon&quot;: &quot;^1.14.7&quot;
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step3:&lt;/b&gt; Create new folder &#39;&lt;b&gt;views&lt;/b&gt;&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step4:&lt;/b&gt; In views folder create new file &lt;b&gt;index.ejs&lt;/b&gt; and add following code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
  &amp;lt;title&amp;gt;Basic CRUD Example&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;ul class=&quot;quotes&quot;&amp;gt;
  &amp;lt;% for(var i=0; i&amp;lt;data.length; i++) {%&amp;gt;
    &amp;lt;li class=&quot;quote&quot;&amp;gt;
      &amp;lt;span&amp;gt;&amp;lt;%= data[i].name %&amp;gt;: &amp;lt;/span&amp;gt;
      &amp;lt;span&amp;gt;&amp;lt;%= data[i].address %&amp;gt;&amp;lt;/span&amp;gt;
      &amp;lt;!--&amp;lt;span&amp;gt;&amp;lt;%= data[i]._id %&amp;gt;&amp;lt;/span&amp;gt;--&amp;gt;
      &amp;lt;a href=&quot;update/&amp;lt;%= data[i]._id %&amp;gt;&quot;&amp;gt;Update&amp;lt;/a&amp;gt;
      &amp;lt;a href=&quot;delete/&amp;lt;%= data[i]._id %&amp;gt;&quot;&amp;gt;Delete&amp;lt;/a&amp;gt;
    &amp;lt;/li&amp;gt;
  &amp;lt;% } %&amp;gt;
  &amp;lt;/ul&amp;gt;

  &amp;lt;form action=&quot;/addnew&quot; method=&quot;POST&quot;&amp;gt;
    &amp;lt;input type=&quot;text&quot; placeholder=&quot;name&quot; name=&quot;name&quot;&amp;gt;
    &amp;lt;input type=&quot;text&quot; placeholder=&quot;address&quot; name=&quot;address&quot;&amp;gt;
    &amp;lt;button type=&quot;submit&quot;&amp;gt;Submit&amp;lt;/button&amp;gt;
  &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Step5:&lt;/b&gt; In views folder create new file &lt;b&gt;update.ejs&lt;/b&gt; and add following code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
  &amp;lt;title&amp;gt;Basic CRUD Example&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;form action=&quot;/updatepost&quot; method=&quot;POST&quot;&amp;gt;
    &amp;lt;input style=&quot;width:300px;&quot; type=&quot;text&quot; placeholder=&quot;name&quot; name=&quot;name&quot; value=&quot;&amp;lt;%= data[0].name %&amp;gt;&quot;&amp;gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input style=&quot;width:300px;&quot; type=&quot;text&quot; placeholder=&quot;address&quot; name=&quot;address&quot; value=&quot;&amp;lt;%= data[0].address %&amp;gt;&quot;&amp;gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input style=&quot;width:300px;&quot; type=&quot;text&quot; placeholder=&quot;id&quot; name=&quot;id&quot; value=&quot;&amp;lt;%= data[0]._id %&amp;gt;&quot;&amp;gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;a href=&quot;/&quot;&amp;gt;Back&amp;lt;/a&amp;gt;
    &amp;lt;button type=&quot;submit&quot;&amp;gt;Update&amp;lt;/button&amp;gt;

  &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;Make sure you have added all required node module in your application. You can download required module from &lt;a href=&quot;https://goo.gl/dNfF19&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;https://goo.gl/dNfF19&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/4229534432202669862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2018/01/basic-crud-application-with-express-and-mongodb.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4229534432202669862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4229534432202669862'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2018/01/basic-crud-application-with-express-and-mongodb.html' title='Basic Simple CRUD Application with Express and MongoDB'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2dtLzVwB-7oXjkT2rnRTfV5pt2ApeW-LWPJGFPhMwTW28VqzBe_lLRcbLNF2sblYelCBo13kvOY5q75n8m6fbPK-pAjssqnRafF1Izl_yAczYcMQpT63YJ0BYxHz2JAzj5K9_hf1D9cU/s72-c/crud-express-mongodb.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-108184694074685176</id><published>2017-09-05T22:44:00.002-07:00</published><updated>2017-09-11T02:03:37.747-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>PayEase Payment Gateway For Magento 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
PayEase is the payment service provider in China. After converting our client site to Magento 2, i tried to find Payease payment extension. But unfortunately Payease was not there. So we are unable to process payment without Payease payment method. That is why i have developed my custom PayEase extension for Magento 2. I hope this will help someone else.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0L0itsUTMeZGp-b7NsVVNPMW1CulGTdANH3SWOKDHv-Tyk3WQ-OkLpLfHc4KfWQpTaob_sqsX62dsDq1Vhz7Nusn9Su3kN5JBnLuCBc1ElnC6V4iI4n0TcCBJjjjFJNq_pvCag3mM4g/s1600/payease-payment-method-magento2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;payease-payment-method-magento2&quot; border=&quot;0&quot; data-original-height=&quot;767&quot; data-original-width=&quot;1289&quot; height=&quot;380&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0L0itsUTMeZGp-b7NsVVNPMW1CulGTdANH3SWOKDHv-Tyk3WQ-OkLpLfHc4KfWQpTaob_sqsX62dsDq1Vhz7Nusn9Su3kN5JBnLuCBc1ElnC6V4iI4n0TcCBJjjjFJNq_pvCag3mM4g/s640/payease-payment-method-magento2.png&quot; title=&quot;PayEase Payment Gateway For Magento 2&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;https://goo.gl/xr99it&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/108184694074685176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2017/09/payease-payment-gateway-for-magento-2.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/108184694074685176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/108184694074685176'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2017/09/payease-payment-gateway-for-magento-2.html' title='PayEase Payment Gateway For Magento 2'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0L0itsUTMeZGp-b7NsVVNPMW1CulGTdANH3SWOKDHv-Tyk3WQ-OkLpLfHc4KfWQpTaob_sqsX62dsDq1Vhz7Nusn9Su3kN5JBnLuCBc1ElnC6V4iI4n0TcCBJjjjFJNq_pvCag3mM4g/s72-c/payease-payment-method-magento2.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-1455579108622823915</id><published>2017-06-14T00:07:00.000-07:00</published><updated>2017-06-14T00:09:13.265-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>Magento2 – Write Custom Mysql Query In External File</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here we learn how to write custom mysql add, update or delete query in external file&lt;br /&gt;
&lt;br /&gt;
Suppose we have table ’&lt;b&gt;employee&lt;/b&gt;’ with fields &lt;b&gt;emp_id&lt;/b&gt;, &lt;b&gt;emp_name&lt;/b&gt;, &lt;b&gt;emp_code&lt;/b&gt; and &lt;b&gt;emp_salary&lt;/b&gt;.
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;use Magento\Framework\App\Bootstrap;
require $_SERVER[&quot;DOCUMENT_ROOT&quot;] . &#39;/app/bootstrap.php&#39;;
 
$params = $_SERVER;
 
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap-&amp;gt;getObjectManager();
$resource = $objectManager-&amp;gt;get(&#39;Magento\Framework\App\ResourceConnection&#39;);
$connection = $resource-&amp;gt;getConnection();
$tableName = $resource-&amp;gt;getTableName(&#39;employee&#39;); //table name with prefix

//Select Data from table
$sql = &quot;Select * FROM &quot; . $tableName;
$result = $connection-&amp;gt;fetchAll($sql); // gives associated array, table fields as key in array.
 
//Delete Data from table
$sql = &quot;Delete FROM &quot; . $tableName.&quot; Where emp_id = 10&quot;;
$connection-&amp;gt;query($sql);
 
//Insert Data into table
$sql = &quot;Insert Into &quot; . $tableName . &quot; (emp_id, emp_name, emp_code, emp_salary) Values (&#39;&#39;,&#39;XYZ&#39;,&#39;ABD20&#39;,&#39;50000&#39;)&quot;;
$connection-&amp;gt;query($sql);
 
//Update Data into table
$sql = &quot;Update &quot; . $tableName . &quot;Set emp_salary = 20000 where emp_id = 12&quot;;
$connection-&amp;gt;query($sql);
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/1455579108622823915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2017/06/magento2-custom-mysql-query.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1455579108622823915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1455579108622823915'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2017/06/magento2-custom-mysql-query.html' title='Magento2 – Write Custom Mysql Query In External File'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-2993915969454634183</id><published>2017-05-12T00:05:00.000-07:00</published><updated>2017-05-12T00:05:30.408-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>Magento 2 Stock control issue in Cancelled/Failed order</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I experience a problem with stock control in Magento 2. After placing an order, the inventory is reduced. However, when i cancel the payment, the qty is increased by 2. It looks like restoring the cart results in increasing the stocks, as well as canceling the order. So i think there is something wrong in magento&#39;s restore cart function.&lt;br /&gt;
&lt;br /&gt;
You can remove the event that increases the stock on restoring a quote.&lt;br /&gt;
This will require an edit in a magento core file.&lt;br /&gt;
&lt;br /&gt;
In: vendor/magento/module-catalog-inventory/etc/events.xml&lt;br /&gt;
&lt;br /&gt;
remove:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;event name=&quot;restore_quote&quot;&amp;gt;
  &amp;lt;observer name=&quot;inventory&quot; instance=&quot;Magento\CatalogInventory\Observer\RevertQuoteInventoryObserver&quot;/&amp;gt;
&amp;lt;/event&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/2993915969454634183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2017/05/magento-2-stock-control-issue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/2993915969454634183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/2993915969454634183'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2017/05/magento-2-stock-control-issue.html' title='Magento 2 Stock control issue in Cancelled/Failed order'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-4354918782137654815</id><published>2017-02-15T22:42:00.001-08:00</published><updated>2017-02-15T23:06:07.253-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>Magento 2: Override/Rewrite Wishlist controller</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In seeking how to override a controller in Magento 2, you find lots of different ways to proceed. Some work, some do not. I will show you how to override a controller very easily. I am going to override&amp;nbsp;wishlist controller. Lets see step by step how to do.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhltoxZ-icKQPnUcyDFjXcaTVqb2ze1iuEMeNamZ9sSdAyTJDFjlBbYMyRq63V8R4qDeTzcTWql-txegyA_C01XbR1UGOa_7l-Us4IcYpbscnOVmToMvkD8rJl1RGFDn5IovNHcnOWsP14/s1600/magento-2-overriderewrite-w.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Magento 2: Override/Rewrite Wishlist controller&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhltoxZ-icKQPnUcyDFjXcaTVqb2ze1iuEMeNamZ9sSdAyTJDFjlBbYMyRq63V8R4qDeTzcTWql-txegyA_C01XbR1UGOa_7l-Us4IcYpbscnOVmToMvkD8rJl1RGFDn5IovNHcnOWsP14/s1600/magento-2-overriderewrite-w.png&quot; title=&quot;Magento 2: Override/Rewrite Wishlist controller&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Step1: Create&amp;nbsp;directory structure&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
app/code/HK/Localwishlist/Controller/Wishlist/Add.php&lt;/div&gt;
&lt;div&gt;
app/code/HK/Localwishlist/etc/di.xml&lt;/div&gt;
&lt;div&gt;
app/code/HK/Localwishlist/etc/module.xml&lt;/div&gt;
&lt;div&gt;
app/code/HK/Localwishlist/registration.php&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Step2: Add this code in your Add.php file&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
namespace HK\Localwishlist\Controller\Wishlist;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\App\Action;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Controller\ResultFactory;

/**
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Add extends \Magento\Wishlist\Controller\AbstractIndex
{
    /**
     * @var \Magento\Wishlist\Controller\WishlistProviderInterface
     */
    protected $wishlistProvider;

    /**
     * @var \Magento\Customer\Model\Session
     */
    protected $_customerSession;

    /**
     * @var ProductRepositoryInterface
     */
    protected $productRepository;

    /**
     * @param Action\Context $context
     * @param \Magento\Customer\Model\Session $customerSession
     * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider
     * @param ProductRepositoryInterface $productRepository
     */
    public function __construct(
        Action\Context $context,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider,
        ProductRepositoryInterface $productRepository
    ) {
        $this-&amp;gt;_customerSession = $customerSession;
        $this-&amp;gt;wishlistProvider = $wishlistProvider;
        parent::__construct($context);
        $this-&amp;gt;productRepository = $productRepository;
    }

    public function execute(){
            
        echo &quot;Test.....&quot;;
        
    }
}
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Step3: Add this code in your&amp;nbsp;di.xml&amp;nbsp;file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd&quot;&amp;gt;
        &amp;lt;preference for=&quot;Magento\Wishlist\Controller\Index\Add&quot; type=&quot;HK\Localwishlist\Controller\Wishlist\Add&quot; /&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Step4: Add this code in your&amp;nbsp;module.xml&amp;nbsp;file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd&quot;&amp;gt;
 &amp;lt;module name=&quot;HK_Localwishlist&quot; setup_version=&quot;1.0.0&quot;/&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Step5: Add this code in your&amp;nbsp;registration.php&amp;nbsp;file&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    &#39;HK_Localwishlist&#39;,
    __DIR__
);
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Now use this command,&lt;br /&gt;
&lt;b&gt;php bin/magento setup:upgrade&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;a class=&quot;newsharepost downloadlink&quot; href=&quot;https://www.dropbox.com/s/lcn3yb8jv3h9ijd/HK_m2_overriderewrite_wishlist_controller.zip&quot; target=&quot;_blank&quot;&gt;Download&lt;/a&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/4354918782137654815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2017/02/magento-2-overriderewrite-wishlist-controller.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4354918782137654815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4354918782137654815'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2017/02/magento-2-overriderewrite-wishlist-controller.html' title='Magento 2: Override/Rewrite Wishlist controller'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhltoxZ-icKQPnUcyDFjXcaTVqb2ze1iuEMeNamZ9sSdAyTJDFjlBbYMyRq63V8R4qDeTzcTWql-txegyA_C01XbR1UGOa_7l-Us4IcYpbscnOVmToMvkD8rJl1RGFDn5IovNHcnOWsP14/s72-c/magento-2-overriderewrite-w.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-3823210495740621906</id><published>2016-12-27T02:23:00.000-08:00</published><updated>2016-12-27T02:23:11.457-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Bitcoin Coinbase API for PHP - Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Bitcoin is an innovative payment network and a new kind of money. Bitcoin is the world&#39;s most widely used alternative currency with a total market cap of approximately $10 billion. The bitcoin network is made up of thousands of computers run by individuals all over the world.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7O6Yhpw5BHHceP4SaJBho2PvSJrI3Q1iTbVkA_ofIDoCckhkTh1nNPdF7bJt_Mb9-w1ni7M19QcfcIGJzTkN9qgUANHYTc09Er76AEOZK7GwFbGYWJ84yqPGWpDrGrA-Q87GSPxWlrBg/s1600/bitcoin-coinbase-api-for-php-example.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Bitcoin Coinbase API for PHP - Example&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7O6Yhpw5BHHceP4SaJBho2PvSJrI3Q1iTbVkA_ofIDoCckhkTh1nNPdF7bJt_Mb9-w1ni7M19QcfcIGJzTkN9qgUANHYTc09Er76AEOZK7GwFbGYWJ84yqPGWpDrGrA-Q87GSPxWlrBg/s1600/bitcoin-coinbase-api-for-php-example.png&quot; title=&quot;Bitcoin Coinbase API for PHP - Example&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here i am going to present a small example to send money with&amp;nbsp;&lt;b&gt;Coinbase API&lt;/b&gt;. You can create a new payment button with Coinbase api. Let see step by step how it will work.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Step 1: Create a payment.php file&lt;/b&gt;&lt;/h4&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
require __DIR__ . &#39;/vendor/autoload.php&#39;;

use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Value\Money;
use Coinbase\Wallet\Resource\Checkout;
use Coinbase\Wallet\Resource\Order;
    
$apiKey = &#39;API KEY&#39;;
$apiSecret = &#39;API SECRET&#39;;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

$amount = 0.1;
$orderId = &quot;YOUR ORDER ID&quot;;

$params = array(
    &#39;name&#39;          =&amp;gt; &#39;Site order ID: &#39;.$orderId,
    &#39;amount&#39;        =&amp;gt; new Money($amount, &#39;USD&#39;),
    &#39;metadata&#39;      =&amp;gt; array(&#39;order_id&#39; =&amp;gt; $orderId),
    &#39;auto_redirect&#39; =&amp;gt; true
);

$checkout = new Checkout($params);
$client-&amp;gt;createCheckout($checkout);
$code = $checkout-&amp;gt;getEmbedCode();

$redirect_url = &quot;https://www.coinbase.com/checkouts/$code&quot;;
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Step 2: Create a notification.php file&lt;/b&gt;&lt;/h4&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php 
require __DIR__ . &#39;/vendor/autoload.php&#39;;

use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Value\Money;
use Coinbase\Wallet\Resource\Checkout;
use Coinbase\Wallet\Resource\Order;

$apiKey = &#39;API KEY&#39;;
$apiSecret = &#39;API SECRET&#39;;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

$raw_body = file_get_contents(&#39;php://input&#39;);
$signature = $_SERVER[&#39;HTTP_CB_SIGNATURE&#39;];
$authenticity = $client-&amp;gt;verifyCallback($raw_body, $signature); // boolean
if($authenticity){
 $order = json_decode($raw_body, true);
    mail(&quot;YOUR EMAIL ID&quot;,&quot;Coinbase Patment Notifications&quot;,print_r($order, true));
}
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Step 3: Create a success.php file&lt;/b&gt;&lt;/h4&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
$order = $_GET[&#39;order&#39;];
var_dump($order);
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;You need to set these all files url in your &lt;a href=&quot;https://www.coinbase.com/merchant_settings&quot; target=&quot;_blank&quot;&gt;coinbase merchant account&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/3823210495740621906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/12/bitcoin-coinbase-api-for-php-example.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3823210495740621906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/3823210495740621906'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/12/bitcoin-coinbase-api-for-php-example.html' title='Bitcoin Coinbase API for PHP - Example'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7O6Yhpw5BHHceP4SaJBho2PvSJrI3Q1iTbVkA_ofIDoCckhkTh1nNPdF7bJt_Mb9-w1ni7M19QcfcIGJzTkN9qgUANHYTc09Er76AEOZK7GwFbGYWJ84yqPGWpDrGrA-Q87GSPxWlrBg/s72-c/bitcoin-coinbase-api-for-php-example.png" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-590177729494094264</id><published>2016-12-23T22:45:00.000-08:00</published><updated>2016-12-23T22:46:42.950-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>You Did not Sign in Correctly or Your Account is Temporarily Disabled Magento 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When you try to login to your &lt;b&gt;Magento 2&lt;/b&gt; admin, you got this message &lt;b&gt;You did not sign in correctly or your account is temporarily disabled&lt;/b&gt; . You don’t know that you are not using username or password. In this guide, I will show to how to resolve this sign in problem “You did not sign in correctly or your account is temporarily disabled”.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO_VGzWIEg-YdePtTOOweKJL7LcDHn8GukGhf-PJ1Xn9ZK1dwlSUm_sLuoVYc_NXZn2BmP1hMgIXvRRpKLXKfR1HhCos9esMqMhfHAKiSFHYtPw0nFx6BsY9uD11tBtR3X0O8WduDHReo/s1600/you-did-not-sign-in-correctly-magento2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Your Account is Temporarily Disabled Magento2&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO_VGzWIEg-YdePtTOOweKJL7LcDHn8GukGhf-PJ1Xn9ZK1dwlSUm_sLuoVYc_NXZn2BmP1hMgIXvRRpKLXKfR1HhCos9esMqMhfHAKiSFHYtPw0nFx6BsY9uD11tBtR3X0O8WduDHReo/s1600/you-did-not-sign-in-correctly-magento2.png&quot; title=&quot;Your Account is Temporarily Disabled Magento2&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
The fix was to make sure there is 1 alpha character and 1 numeric character in the admin password. This should be labelled a bug if the password is not validated during install with magento setup:install&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution: Unlock admin account&lt;/h2&gt;
&lt;br /&gt;
try command in case the account is locked
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;php bin/magento admin:user:unlock &lt;username&gt;
&lt;/username&gt;&lt;/pre&gt;
&lt;br /&gt;
Or go to Magento 2 root folder and type
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;php bin/magento admin:user:unlock &lt;username&gt;
&lt;/username&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8rFeAyM_j1cWo3VQYG2XRIrb1h5Mx-J6v30V6XGZYtWC-lq0FYl6RXiQGskNN1y9vClt2nHEiyPa5pfIhnFM0nnq0a27CdvknR-Dqo4JgTakoN3S2dIReiTkCmbDo9KaqW8IggAVh8jg/s1600/you-did-not-sign-in-correctly-magento2-hkpatel201.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Your Account is Temporarily Disabled Magento2&quot; border=&quot;0&quot; height=&quot;323&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8rFeAyM_j1cWo3VQYG2XRIrb1h5Mx-J6v30V6XGZYtWC-lq0FYl6RXiQGskNN1y9vClt2nHEiyPa5pfIhnFM0nnq0a27CdvknR-Dqo4JgTakoN3S2dIReiTkCmbDo9KaqW8IggAVh8jg/s640/you-did-not-sign-in-correctly-magento2-hkpatel201.png&quot; title=&quot;Your Account is Temporarily Disabled Magento2&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/590177729494094264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/12/you-did-not-sign-in-correctly-magento2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/590177729494094264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/590177729494094264'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/12/you-did-not-sign-in-correctly-magento2.html' title='You Did not Sign in Correctly or Your Account is Temporarily Disabled Magento 2'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO_VGzWIEg-YdePtTOOweKJL7LcDHn8GukGhf-PJ1Xn9ZK1dwlSUm_sLuoVYc_NXZn2BmP1hMgIXvRRpKLXKfR1HhCos9esMqMhfHAKiSFHYtPw0nFx6BsY9uD11tBtR3X0O8WduDHReo/s72-c/you-did-not-sign-in-correctly-magento2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-8492513677339967976</id><published>2016-11-14T22:37:00.000-08:00</published><updated>2016-11-14T22:37:17.317-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="magento"/><category scheme="http://www.blogger.com/atom/ns#" term="related product"/><title type='text'>Related product disappear after adding to Cart [Fixed]</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have noticed that after adding a product to cart, it disappears in list of related products. It&#39;s a default Magento feature that after adding an item to cart, it disappears under the related products of a specific product. If you want to still show that specific product even if already added it to cart&amp;nbsp;You need to rewrite the block&lt;span style=&quot;background-color: white; color: #3d4245; font-family: &amp;quot;roboto&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 15px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-color: #eceff1; border: 0px; color: #3d4245; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; margin: 0px; padding: 1px 5px; white-space: pre-wrap;&quot;&gt;Mage_Catalog_Block_Product_List_Related&lt;/code&gt;&lt;span style=&quot;background-color: white; color: #3d4245; font-family: &amp;quot;roboto&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 15px;&quot;&gt;&amp;nbsp;&lt;/span&gt;and from the method&lt;span style=&quot;background-color: white; color: #3d4245; font-family: &amp;quot;roboto&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 15px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-color: #eceff1; border: 0px; color: #3d4245; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; margin: 0px; padding: 1px 5px; white-space: pre-wrap;&quot;&gt;_prepareData&lt;/code&gt;&lt;span style=&quot;background-color: white; color: #3d4245; font-family: &amp;quot;roboto&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 15px;&quot;&gt;&amp;nbsp;&lt;/span&gt;comment following line&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;Mage::getResourceSingleton(&#39;checkout/cart&#39;)-&amp;gt;addExcludeProductFilter($this-&amp;gt;_itemCollection, 
    Mage::getSingleton(&#39;checkout/session&#39;)-&amp;gt;getQuoteId()
);
&lt;/pre&gt;
&lt;br /&gt;
It is a good&amp;nbsp;practice to not change any core file. Better to over write this file in your local folder. Create directory like&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;/app/code/local/Mage/Catalog/Block/Product/List&lt;/b&gt;&amp;nbsp;and copy&amp;nbsp;&lt;i&gt;Related.php&lt;/i&gt;&amp;nbsp;file in this directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/8492513677339967976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/11/related-product-disappear-after-adding-cart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8492513677339967976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8492513677339967976'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/11/related-product-disappear-after-adding-cart.html' title='Related product disappear after adding to Cart [Fixed]'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-7972315258358171112</id><published>2016-10-29T05:00:00.003-07:00</published><updated>2016-10-29T05:00:55.509-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>Get the Hash ( # ) value from url using jQuery or Javascript</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Get the value after a hash in the URL of the current page.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-javascript&quot;&gt;var hash = window.location.hash.substr(1);
alert(hash);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/7972315258358171112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/10/get-hash-value-from-url-using-jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7972315258358171112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7972315258358171112'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/10/get-hash-value-from-url-using-jquery.html' title='Get the Hash ( # ) value from url using jQuery or Javascript'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-7463835934187722837</id><published>2016-09-07T23:10:00.003-07:00</published><updated>2016-09-07T23:47:25.416-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Generating Random Names With PHP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This is a short tutorial on how to generate random names with PHP. With PHP you can automatically generate random name using this script.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
In this example, we have two PHP arrays. One contains a list of common names. The other contains a list of common surnames. Using the function &lt;a href=&quot;http://php.net/manual/en/function.mt-rand.php&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;mt_rand&lt;/a&gt;.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiAI3E_W79L_4VzzxvHM86a3LOO51ipA29Vj0QuRpPCuQV08683xmAwT7Y008-ulF4ALmzWOXYiqtBZiWKjBld71klmklWQ6iyI29ef5Dfb34nG0cAOG2dySA-YDGMcfE5edZ8QFjuS5g/s1600/generating-random-names-wit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;PHP&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiAI3E_W79L_4VzzxvHM86a3LOO51ipA29Vj0QuRpPCuQV08683xmAwT7Y008-ulF4ALmzWOXYiqtBZiWKjBld71klmklWQ6iyI29ef5Dfb34nG0cAOG2dySA-YDGMcfE5edZ8QFjuS5g/s1600/generating-random-names-wit.png&quot; title=&quot;Generating Random Names With PHP&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a class=&quot;downloadlink&quot; href=&quot;http://www.developersarea.xyz/demos/php/generating-random-names/&quot; target=&quot;_blank&quot;&gt;Demo&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;&amp;lt;?php
$names = array(
    &#39;Hardik&#39;,
    &#39;Shivam&#39;,
    &#39;Nirmal&#39;,
    &#39;Kaushik&#39;,
    &#39;Pradip&#39;,
    &#39;Rixit&#39;,
    &#39;Neel&#39;,
    &#39;Samantha&#39;,
);
 
//PHP array containing surnames.
$surnames = array(
    &#39;Patel&#39;,
    &#39;Thompson&#39;,
    &#39;Anderson&#39;,
    &#39;Johnson&#39;,
    &#39;Tremblay&#39;,
    &#39;Peltier&#39;,
    &#39;Cunningham&#39;,
    &#39;Simpson&#39;,
    &#39;Mercado&#39;,
    &#39;Sellers&#39;
);
 
//Generate a random name.
$random_name = $names[mt_rand(0, sizeof($names) - 1)];
 
//Generate a random surname.
$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)];
 
//Combine them together and print out the result.
echo $random_name . &#39; &#39; . $random_surname;
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/7463835934187722837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/09/generating-random-names-with-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7463835934187722837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/7463835934187722837'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/09/generating-random-names-with-php.html' title='Generating Random Names With PHP'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiAI3E_W79L_4VzzxvHM86a3LOO51ipA29Vj0QuRpPCuQV08683xmAwT7Y008-ulF4ALmzWOXYiqtBZiWKjBld71klmklWQ6iyI29ef5Dfb34nG0cAOG2dySA-YDGMcfE5edZ8QFjuS5g/s72-c/generating-random-names-wit.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-1772640149332194992</id><published>2016-07-29T23:03:00.000-07:00</published><updated>2016-07-29T23:03:53.150-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>PHP Get Different Number On Page Refresh</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This simple php script allow you to get different number on every page refresh. If you want to change value of your php variable on page refresh, this script will help you. Let say i have a default value 1 and want to change it for 2 on page refresh and again 2 to 1 on next page refresh.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;if(!isset($_SESSION[&#39;changenumber&#39;])){
    $_SESSION[&#39;changenumber&#39;] = 1;
}
if($_SESSION[&#39;changenumber&#39;] == 1){
    $_SESSION[&#39;changenumber&#39;] = 2;
}else{
    $_SESSION[&#39;changenumber&#39;] = 1;
}
echo $_SESSION[&#39;changenumber&#39;];&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/1772640149332194992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/07/php-get-different-number-on-page-refresh.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1772640149332194992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1772640149332194992'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/07/php-get-different-number-on-page-refresh.html' title='PHP Get Different Number On Page Refresh'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-1270622719525613338</id><published>2016-07-28T00:31:00.001-07:00</published><updated>2016-07-28T00:31:47.149-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>PHP Find URLs in Text And Make Hyper Link</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The basic function of this is to find any URLs in the block of text and turn them into hyperlinks.&lt;br /&gt;
&lt;div&gt;
It will only find URLs if they are properly formatted, meaning they have a www, http, https, ftp or ftps.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMCcdf6QHpzhLdUMxZ8eQ1MQQnUrRsnY0xgqVqkQSHJrD-nu-SnbsH0kD6bYUSUKAIL6WwrWzfhuyQszcaI8qsMbBYWDY277BF4zLDyp115uMvmDI7E8MvfrgUyx1a_LgzrB5DDQ6vwT4/s1600/php-find-urls-in-text-and-make-link.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;TextToHyperlink&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMCcdf6QHpzhLdUMxZ8eQ1MQQnUrRsnY0xgqVqkQSHJrD-nu-SnbsH0kD6bYUSUKAIL6WwrWzfhuyQszcaI8qsMbBYWDY277BF4zLDyp115uMvmDI7E8MvfrgUyx1a_LgzrB5DDQ6vwT4/s1600/php-find-urls-in-text-and-make-link.png&quot; title=&quot;PHP Find URLs in Text And Make Hyper Link&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;function textTohyperlink($text) {
    // The Regular Expression filter
    $reg_exUrl = &quot;/((((http|https|ftp|ftps)\:\/\/)|www\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}(\/\S*)?)/&quot;;

    // Check if there is a url in the text
    if(preg_match_all($reg_exUrl, $text, $url)) {
           // make the urls hyper links
           $matches = array_unique($url[0]);
           foreach($matches as $match) {
                $replacement = &quot;&amp;lt;a href=&quot;.$match.&quot; target=&#39;_blank&#39; rel=&#39;nofollow&#39;&amp;gt;{$match}&amp;lt;/a&amp;gt;&quot;;
                $text = str_replace($match,$replacement,$text);
           }
           return nl2br($text);
    } else {
           // if no urls in the text just return the text
           return nl2br($text);
    }
}

$text = &quot;The text you want to filter goes here. http://hkpatel201.blogspot.com&quot;;
echo textTohyperlink($text);
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/1270622719525613338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/07/php-find-urls-in-text-and-make-link.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1270622719525613338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1270622719525613338'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/07/php-find-urls-in-text-and-make-link.html' title='PHP Find URLs in Text And Make Hyper Link'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMCcdf6QHpzhLdUMxZ8eQ1MQQnUrRsnY0xgqVqkQSHJrD-nu-SnbsH0kD6bYUSUKAIL6WwrWzfhuyQszcaI8qsMbBYWDY277BF4zLDyp115uMvmDI7E8MvfrgUyx1a_LgzrB5DDQ6vwT4/s72-c/php-find-urls-in-text-and-make-link.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-4020388164615494531</id><published>2016-06-14T00:50:00.000-07:00</published><updated>2016-06-14T03:08:36.478-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="htaccess"/><title type='text'>htaccess Temporary Redirect to Maintenance Page</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Redirecting visitors to a maintenance page or other temporary page is most important thing while you are updating your site and don&#39;t want users to access your site. Using htaccess you can redirect your visitors to a temporary maintenance page. All you need to redirect your visitors is the following code placed in your site’s root htaccess:
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigK2KIxeRjcsqwcpiSheVCOgS22FwJPw3Upx_agpT0KietvAuHxkUh32T9rhIMJIEgzVPpy_v6cEbSq2RazNA2FXWQm5XP6-HxL_p9jEAdZMh17mJ48yz8Ma5JXLkYTVyNnBLx3QlIEzw/s1600/htaccess-temporary-maintenance-redirect-hkblog.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;htaccess Temporary Redirect to Maintenance Page&quot; border=&quot;0&quot; height=&quot;306&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigK2KIxeRjcsqwcpiSheVCOgS22FwJPw3Upx_agpT0KietvAuHxkUh32T9rhIMJIEgzVPpy_v6cEbSq2RazNA2FXWQm5XP6-HxL_p9jEAdZMh17mJ48yz8Ma5JXLkYTVyNnBLx3QlIEzw/s640/htaccess-temporary-maintenance-redirect-hkblog.jpg&quot; title=&quot;htaccess Temporary Redirect to Maintenance Page&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;RewriteCond %{REQUEST_URI} !maintenance.html
RewriteCond %{REQUEST_FILENAME} !(styles|images).+$
RewriteCond %{REMOTE_ADDR} !^555\.555\.555\.555$
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule (.*) /maintenance.html [R,L]
&lt;/pre&gt;
&lt;br /&gt;
This code makes it easy to temporarily put down your website for updates.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;If you only want to access site, you need to change &quot;REMOTE_ADDR&quot; with your own IP address. Images and styles are allowed to pass through the filter as well.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/4020388164615494531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/06/htaccess-temporary-maintenance-redirect.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4020388164615494531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/4020388164615494531'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/06/htaccess-temporary-maintenance-redirect.html' title='htaccess Temporary Redirect to Maintenance Page'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigK2KIxeRjcsqwcpiSheVCOgS22FwJPw3Upx_agpT0KietvAuHxkUh32T9rhIMJIEgzVPpy_v6cEbSq2RazNA2FXWQm5XP6-HxL_p9jEAdZMh17mJ48yz8Ma5JXLkYTVyNnBLx3QlIEzw/s72-c/htaccess-temporary-maintenance-redirect-hkblog.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-1644562534477393673</id><published>2016-06-10T11:47:00.001-07:00</published><updated>2016-06-10T22:48:27.122-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><category scheme="http://www.blogger.com/atom/ns#" term="Social Share"/><title type='text'>Social Share In Popup Using jQuery</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Simple jQuery and html script to share your content on Social networks. Social sharing buttons are necessary to make it easy for visitors to 
share your content on professional networks like Facebook, Google, Twitter, 
linkedin, tumbler etc. In this tutorial you can see how to share your page content on social sites without redirect to that page. This example open a popup on same page to share your page.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBcdiBtFYvFpnTXjbBjA-djARARDOAQTAJBkmmhzWdiEsvpPw04ayt7_0SRl_oWh7ErFhEPRM6iRJrejGHLuAl_g6zVJWABkd8EspLQEBWD68BRhD6R-P_HCkLlZ-bwMW2tbpltSY5xjI/s1600/hkpatel-social-share.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Social Share In Popup Using jQuery&quot; border=&quot;0&quot; height=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBcdiBtFYvFpnTXjbBjA-djARARDOAQTAJBkmmhzWdiEsvpPw04ayt7_0SRl_oWh7ErFhEPRM6iRJrejGHLuAl_g6zVJWABkd8EspLQEBWD68BRhD6R-P_HCkLlZ-bwMW2tbpltSY5xjI/s640/hkpatel-social-share.png&quot; title=&quot;Social Share In Popup Using jQuery&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As web developers, we have to be weary of the slow down that sharing buttons bring. Every button that you include in your page loads its own set of scripts and stylesheets which make your pages slower to load. So if you don&#39;t want to make your page loading speed down, Add html and a simple jQuery to share your page on social network. Now let see how to make it working.&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;downloadlink&quot; href=&quot;http://www.developersarea.xyz/demos/php/social-share-popup/&quot; target=&quot;_blank&quot;&gt;Demo&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;First you need to add hyper links where you want to share&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-html&quot;&gt;  
  &amp;lt;!-- Facebook --&amp;gt;
  &amp;lt;a class=&quot;nohover&quot; href=&quot;http://www.facebook.com/sharer.php?u=http://hkpatel201.blogspot.com&quot; target=&quot;_blank&quot;&amp;gt;
     &amp;lt;img alt=&quot;Facebook&quot; src=&quot;/images/developersarea-facebook-share.png&quot; /&amp;gt;
  &amp;lt;/a&amp;gt;

  &amp;lt;!-- Google+ --&amp;gt;
  &amp;lt;a class=&quot;nohover&quot; href=&quot;https://plus.google.com/share?url=http://hkpatel201.blogspot.com&quot; target=&quot;_blank&quot;&amp;gt;
     &amp;lt;img alt=&quot;Google&quot; src=&quot;/images/developersarea-share-google.png&quot; /&amp;gt;
  &amp;lt;/a&amp;gt;

  &amp;lt;!-- LinkedIn --&amp;gt;
  &amp;lt;a class=&quot;nohover&quot; href=&quot;http://www.linkedin.com/shareArticle?mini=true&amp;amp;amp;url=http://hkpatel201.blogspot.com&quot; target=&quot;_blank&quot;&amp;gt;
     &amp;lt;img alt=&quot;LinkedIn&quot; src=&quot;/images/developersarea-share-linkedin.png&quot; /&amp;gt;
  &amp;lt;/a&amp;gt;

  &amp;lt;!-- Twitter --&amp;gt;
  &amp;lt;a class=&quot;nohover&quot; href=&quot;https://twitter.com/share?url=http://hkpatel201.blogspot.com&amp;amp;amp;text=Developersarea%20Share%20Buttons&amp;amp;amp;hashtags=developersareasharebuttons&quot; target=&quot;_blank&quot;&amp;gt;
     &amp;lt;img alt=&quot;Twitter&quot; src=&quot;/images/developersarea-share-twitter.png&quot; /&amp;gt;
  &amp;lt;/a&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Now it&#39;s time to add jQuery&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-javascript&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
     jQuery(document).ready(function($) {
           jQuery(&#39;#share-buttons a&#39;).on(&#39;click&#39;, function(){
               var width  = 575,
               height = 520,
               left = (jQuery(window).width()  - width)  / 2,
               top = (jQuery(window).height() - height) / 2,
               opts = &#39;status=1&#39; +
                    &#39;,width=&#39;  + width  +
                    &#39;,height=&#39; + height +
                    &#39;,top=&#39;    + top    +
                    &#39;,left=&#39;   + left;
               newwindow=window.open($(this).attr(&#39;href&#39;),&#39;&#39;,opts);
               if (window.focus) {newwindow.focus()}
                  return false;
            });
       });
 &amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/1644562534477393673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/06/social-share-in-popup-using-jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1644562534477393673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/1644562534477393673'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/06/social-share-in-popup-using-jquery.html' title='Social Share In Popup Using jQuery'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBcdiBtFYvFpnTXjbBjA-djARARDOAQTAJBkmmhzWdiEsvpPw04ayt7_0SRl_oWh7ErFhEPRM6iRJrejGHLuAl_g6zVJWABkd8EspLQEBWD68BRhD6R-P_HCkLlZ-bwMW2tbpltSY5xjI/s72-c/hkpatel-social-share.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-8403471535132542214</id><published>2016-03-10T03:15:00.000-08:00</published><updated>2016-03-10T03:24:46.415-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cart rule"/><category scheme="http://www.blogger.com/atom/ns#" term="discount / coupon"/><category scheme="http://www.blogger.com/atom/ns#" term="magento"/><title type='text'>Magento Add Discount To Product Programmatically</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Using this post you can add custom discount to your magento cart total. You can also add discount to cheapest item in cart. Like there are 5 items in your cart and you want to add 30% discount to cheapest item this post will help you. Create new module with following files in your magento. Let&#39;s see step by step how this will work.&lt;br /&gt;
&lt;br /&gt;
&lt;a class=&quot;downloadlink redirectthankyou&quot; href=&quot;https://www.dropbox.com/s/dpam8f0pnf9phv9/HK_Customdiscount.zip&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download Module&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Directories and files needed for the module&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-html&quot;&gt;app/code/local/HK/Customdiscount
app/code/local/HK/Customdiscount/etc
app/code/local/HK/Customdiscount/etc/config.xml
app/code/local/HK/Customdiscount/Model
app/code/local/HK/Customdiscount/Model/Observer.php
app/etc/modules/HK_Customdiscount.xml
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Content of HK_Customdiscount.xml&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-html&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config&amp;gt;
    &amp;lt;modules&amp;gt;
        &amp;lt;HK_Customdiscount&amp;gt;
            &amp;lt;active&amp;gt;true&amp;lt;/active&amp;gt;
            &amp;lt;codePool&amp;gt;local&amp;lt;/codePool&amp;gt;
        &amp;lt;/HK_Customdiscount&amp;gt;
    &amp;lt;/modules&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. etc/config.xml&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-html&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;config&amp;gt;
    &amp;lt;modules&amp;gt;
        &amp;lt;HK_Customdiscount&amp;gt;
            &amp;lt;version&amp;gt;0.1.0&amp;lt;/version&amp;gt;
        &amp;lt;/HK_Customdiscount&amp;gt;
    &amp;lt;/modules&amp;gt;
    
    &amp;lt;global&amp;gt;
        &amp;lt;events&amp;gt;
            &amp;lt;sales_quote_collect_totals_after&amp;gt;
                &amp;lt;observers&amp;gt;
                    &amp;lt;set_custom_discount&amp;gt;
                        &amp;lt;type&amp;gt;singleton&amp;lt;/type&amp;gt;
                        &amp;lt;class&amp;gt;HK_Customdiscount_Model_Observer&amp;lt;/class&amp;gt;
                        &amp;lt;method&amp;gt;setDiscount&amp;lt;/method&amp;gt;
                    &amp;lt;/set_custom_discount&amp;gt;
                &amp;lt;/observers&amp;gt;
            &amp;lt;/sales_quote_collect_totals_after&amp;gt;
        &amp;lt;/events&amp;gt;
    &amp;lt;/global&amp;gt;
&amp;lt;/config&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4. Model/Observer.php&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lagn-php&quot;&gt;&amp;lt;?php
class HK_Customdiscount_Model_Observer extends Varien_Object
{
    public function setDiscount($observer)
    {
       $priceArray;
       
       $quote = $observer-&amp;gt;getEvent()-&amp;gt;getQuote();
       
       /*Enable this code for 30% on cheapest product*/
        /*foreach ($quote-&amp;gt;getAllVisibleItems() as $item) {
            $_incl = Mage::helper(&#39;checkout&#39;)-&amp;gt;getPriceInclTax($item);
            $itmQty = $item-&amp;gt;getQty()&amp;gt;1?$item-&amp;gt;getQty():1;
            for($cnt=1; $cnt &amp;lt;= $itmQty; $cnt++){
                if (Mage::helper(&#39;weee&#39;)-&amp;gt;typeOfDisplay($item, array(0, 1, 4), &#39;sales&#39;) &amp;amp;&amp;amp; $item-&amp;gt;getWeeeTaxAppliedAmount()){
                    $priceArray[] = $_incl + Mage::helper(&#39;weee&#39;)-&amp;gt;getWeeeTaxInclTax($item);
                }else{
                    $priceArray[] = $_incl-$item-&amp;gt;getWeeeTaxDisposition();
                }
            }
        }

        $percentage = 30;
        $discountAmount = ($percentage / 100) * min($priceArray);*/
        
        $discountAmount = 30;
        $quoteid=$quote-&amp;gt;getId();           
        if($quoteid) {
            if($discountAmount&amp;gt;0) {
                $total=$quote-&amp;gt;getBaseSubtotal();
                $quote-&amp;gt;setSubtotal(0);
                $quote-&amp;gt;setBaseSubtotal(0);

                $quote-&amp;gt;setSubtotalWithDiscount(0);
                $quote-&amp;gt;setBaseSubtotalWithDiscount(0);

                $quote-&amp;gt;setGrandTotal(0);
                $quote-&amp;gt;setBaseGrandTotal(0);

                $canAddItems = $quote-&amp;gt;isVirtual()? (&#39;billing&#39;) : (&#39;shipping&#39;); 
                foreach ($quote-&amp;gt;getAllAddresses() as $address) {
                    $address-&amp;gt;setSubtotal(0);
                    $address-&amp;gt;setBaseSubtotal(0);

                    $address-&amp;gt;setGrandTotal(0);
                    $address-&amp;gt;setBaseGrandTotal(0);

                    $address-&amp;gt;collectTotals();

                    $quote-&amp;gt;setSubtotal((float) $quote-&amp;gt;getSubtotal() + $address-&amp;gt;getSubtotal());
                    $quote-&amp;gt;setBaseSubtotal((float) $quote-&amp;gt;getBaseSubtotal() + $address-&amp;gt;getBaseSubtotal());

                    $quote-&amp;gt;setSubtotalWithDiscount(
                        (float) $quote-&amp;gt;getSubtotalWithDiscount() + $address-&amp;gt;getSubtotalWithDiscount()
                    );
                    $quote-&amp;gt;setBaseSubtotalWithDiscount(
                        (float) $quote-&amp;gt;getBaseSubtotalWithDiscount() + $address-&amp;gt;getBaseSubtotalWithDiscount()
                    );

                    $quote-&amp;gt;setGrandTotal((float) $quote-&amp;gt;getGrandTotal() + $address-&amp;gt;getGrandTotal());
                    $quote-&amp;gt;setBaseGrandTotal((float) $quote-&amp;gt;getBaseGrandTotal() + $address-&amp;gt;getBaseGrandTotal());

                    $quote -&amp;gt;save(); 

                    $quote-&amp;gt;setGrandTotal($quote-&amp;gt;getBaseSubtotal()-$discountAmount)
                    -&amp;gt;setBaseGrandTotal($quote-&amp;gt;getBaseSubtotal()-$discountAmount)
                    -&amp;gt;setSubtotalWithDiscount($quote-&amp;gt;getBaseSubtotal()-$discountAmount)
                    -&amp;gt;setBaseSubtotalWithDiscount($quote-&amp;gt;getBaseSubtotal()-$discountAmount)
                    -&amp;gt;save(); 


                    if($address-&amp;gt;getAddressType()==$canAddItems) {
                    //echo $address-&amp;gt;setDiscountAmount; exit;
                     $address-&amp;gt;setSubtotalWithDiscount((float) $address-&amp;gt;getSubtotalWithDiscount()-$discountAmount);
                     $address-&amp;gt;setGrandTotal((float) $address-&amp;gt;getGrandTotal()-$discountAmount);
                     $address-&amp;gt;setBaseSubtotalWithDiscount((float) $address-&amp;gt;getBaseSubtotalWithDiscount()-$discountAmount);
                     $address-&amp;gt;setBaseGrandTotal((float) $address-&amp;gt;getBaseGrandTotal()-$discountAmount);
                     if($address-&amp;gt;getDiscountDescription()){
                     $address-&amp;gt;setDiscountAmount(-($address-&amp;gt;getDiscountAmount()-$discountAmount));
                     $address-&amp;gt;setDiscountDescription($address-&amp;gt;getDiscountDescription().&#39;, Custom Discount&#39;);
                     $address-&amp;gt;setBaseDiscountAmount(-($address-&amp;gt;getBaseDiscountAmount()-$discountAmount));
                     }else {
                     $address-&amp;gt;setDiscountAmount(-($discountAmount));
                     $address-&amp;gt;setDiscountDescription(&#39;Custom Discount&#39;);
                     $address-&amp;gt;setBaseDiscountAmount(-($discountAmount));
                     }
                     $address-&amp;gt;save();
                    }//end: if
               } //end: foreach
               //echo $quote-&amp;gt;getGrandTotal();
                foreach($quote-&amp;gt;getAllItems() as $item){
                 //We apply discount amount based on the ratio between the GrandTotal and the RowTotal
                 $rat=$item-&amp;gt;getPriceInclTax()/$total;
                 $ratdisc=$discountAmount*$rat;
                 $item-&amp;gt;setDiscountAmount(($item-&amp;gt;getDiscountAmount()+$ratdisc) * $item-&amp;gt;getQty());
                 $item-&amp;gt;setBaseDiscountAmount(($item-&amp;gt;getBaseDiscountAmount()+$ratdisc) * $item-&amp;gt;getQty())-&amp;gt;save();

               }    
            }
        }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
That&#39;s it. Hope you are enjoying this post.
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/8403471535132542214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/03/magento-add-discount-to-product.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8403471535132542214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8403471535132542214'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/03/magento-add-discount-to-product.html' title='Magento Add Discount To Product Programmatically'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-587910585357726553</id><published>2016-03-01T03:54:00.001-08:00</published><updated>2016-03-01T03:55:30.000-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="magento"/><category scheme="http://www.blogger.com/atom/ns#" term="magento beginner"/><title type='text'>Magento: Order Confirmation Email Is Not Sent in magento 1.9.1 [Fixed]</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are facing issue like order confirmation email is not going to sent to customer after success order, just make a small change in order.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;app/code/core/Mage/Sales/Model/Order.php&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
First, create one directory structure on the path below, then copy and paste the file to the path below.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;app/code/local/Mage/Sales/Model/Order.php&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Now, change from&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;$mailer-&amp;gt;setQueue($emailQueue)-&amp;gt;send();&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
to&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;$mailer-&amp;gt;send();&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
That&#39;s it. I hope this will help some.&lt;/div&gt;
&lt;div&gt;
Thanks.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/587910585357726553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/03/magento-order-confirmation-email-issue.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/587910585357726553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/587910585357726553'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/03/magento-order-confirmation-email-issue.html' title='Magento: Order Confirmation Email Is Not Sent in magento 1.9.1 [Fixed]'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-8849569912433557701</id><published>2016-02-29T02:27:00.001-08:00</published><updated>2016-06-01T22:55:38.634-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="magento"/><category scheme="http://www.blogger.com/atom/ns#" term="magento beginner"/><title type='text'>Redirect Customer to Previous Page After Successful Login - Magento</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In Magento by default, customers are redirected to ‘Customer Account Dashboard’ page after login. This feature can be easily changed from Magento configuration settings.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Configuration Settings&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Login to admin panel&lt;/li&gt;
&lt;li&gt;Go to System -&amp;gt; Configuration -&amp;gt; CUSTOMERS -&amp;gt; Customer Configuration -&amp;gt; Login Options&lt;/li&gt;
&lt;li&gt;Set: Redirect Customers to Account Dashboard after Loggin in = No&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKlUiiejcpRoHFwMXA_xN8JLcbXamTB_K6ggjOsBMC8GGfLvZJmQn6x1RKMjXcfBqYnsqnCi_LPoxoWBP24hbgHVo5KmmMDRW5N9T6NKGebuWKB0l_7Mdy51vwtPE3MEUro_bMNsx8b9A/s1600/magento-redirect-customer-to-previous-page.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Magento customer configuration&quot; border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKlUiiejcpRoHFwMXA_xN8JLcbXamTB_K6ggjOsBMC8GGfLvZJmQn6x1RKMjXcfBqYnsqnCi_LPoxoWBP24hbgHVo5KmmMDRW5N9T6NKGebuWKB0l_7Mdy51vwtPE3MEUro_bMNsx8b9A/s400/magento-redirect-customer-to-previous-page.png&quot; title=&quot;Magento customer configuration&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
This setting will redirect customers to the page from where they have come to login page. This setting is applicable for all pages of your Magento website.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
You might have another condition of having this feature only on some specific pages.&lt;br /&gt;
&lt;div&gt;
For example, you might want this feature only on product view page. Or, you might have a category that is visible to logged in customers only. In this case, you can simply use the following code:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Redirect customer to login page for&amp;nbsp;specific pages.&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-php&quot;&gt;if(!Mage::helper(&#39;customer&#39;)-&amp;gt;isLoggedIn()) {
 Mage::getSingleton(&#39;customer/session&#39;)
            -&amp;gt;setBeforeAuthUrl(Mage::helper(&#39;core/url&#39;)-&amp;gt;getCurrentUrl()); 
 $this-&amp;gt;_redirect(&#39;customer/account/login&#39;);
}
&lt;/pre&gt;
&lt;br /&gt;
Customers will be redirected to previous page after successful login.&lt;br /&gt;
&lt;br /&gt;
Hope this will help. Thanks.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/8849569912433557701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/02/magento-redirect-customer-to-previous-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8849569912433557701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/8849569912433557701'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/02/magento-redirect-customer-to-previous-page.html' title='Redirect Customer to Previous Page After Successful Login - Magento'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKlUiiejcpRoHFwMXA_xN8JLcbXamTB_K6ggjOsBMC8GGfLvZJmQn6x1RKMjXcfBqYnsqnCi_LPoxoWBP24hbgHVo5KmmMDRW5N9T6NKGebuWKB0l_7Mdy51vwtPE3MEUro_bMNsx8b9A/s72-c/magento-redirect-customer-to-previous-page.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5862994791655053372.post-5187533519130411879</id><published>2016-02-03T08:35:00.001-08:00</published><updated>2016-06-01T22:55:05.948-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Magento2"/><title type='text'>Magento2 php settings check error fixed</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Today i was trying to install Magento 2.0. After starting on second screen of setup step, there is &lt;b&gt;Readiness Check&lt;/b&gt; of Magento Installer. This will check for compatibility of magento 2.0 in your php server. I see there is a &lt;b&gt;PHP Settings Check&lt;/b&gt; issue on my wamp server. So let&#39;s see how to fix this issue.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCMFp2Dw5Wf9MPvQsmhnGvMKoD0dhDjRcaOUy6IhgbE8gO4yXbpPTucAN_eJS6mbTyv7gLOdAo9LZ1e6wZgU-9hMfMjTO0ZGzWyIkH3n-aU1d0lleHYjxFEJP1N0AumSP2QyPVExTmpLQ/s1600/magento-php-settings-check-error-fixed.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img alt=&quot;Magento2 PHP setting check&quot; border=&quot;0&quot; height=&quot;403&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCMFp2Dw5Wf9MPvQsmhnGvMKoD0dhDjRcaOUy6IhgbE8gO4yXbpPTucAN_eJS6mbTyv7gLOdAo9LZ1e6wZgU-9hMfMjTO0ZGzWyIkH3n-aU1d0lleHYjxFEJP1N0AumSP2QyPVExTmpLQ/s640/magento-php-settings-check-error-fixed.png&quot; title=&quot;Magento2 PHP setting check&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Magento 2 is required xdebug.max_nesting_level = 200 or more when there is 100 in my current wamp server setting. To fix this issue you need to change in your &lt;b&gt;php.ini&lt;/b&gt; file. Go to &lt;b&gt;php.ini&lt;/b&gt; file and add following line in that file&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;xdebug.max_nesting_level = 200
&lt;/pre&gt;
&lt;br /&gt;
Now you need to restart your wamp server.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hkpatel201.blogspot.com/feeds/5187533519130411879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hkpatel201.blogspot.com/2016/02/magento-php-settings-check-error-fixed.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/5187533519130411879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5862994791655053372/posts/default/5187533519130411879'/><link rel='alternate' type='text/html' href='http://hkpatel201.blogspot.com/2016/02/magento-php-settings-check-error-fixed.html' title='Magento2 php settings check error fixed'/><author><name>Hardik</name><uri>http://www.blogger.com/profile/15216924252175241111</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCMFp2Dw5Wf9MPvQsmhnGvMKoD0dhDjRcaOUy6IhgbE8gO4yXbpPTucAN_eJS6mbTyv7gLOdAo9LZ1e6wZgU-9hMfMjTO0ZGzWyIkH3n-aU1d0lleHYjxFEJP1N0AumSP2QyPVExTmpLQ/s72-c/magento-php-settings-check-error-fixed.png" height="72" width="72"/><thr:total>3</thr:total></entry></feed>