Thursday 30 April 2015

Print query in magento

/----------Get products collection --------------/
  1. <p>$allproducts = Mage::getModel('catalog/product')-&gt;getCollection()-&gt;addAttributeToSort('name', 'ASC');;</p>
It will return you total products, sorted by name in ascending order from magento database. To print query write the below statement :-
  1. <p>echo $allproducts-&gt;getSelect();</p>

For such more Blogs you can visit to http://findnerd.com/NerdDigest


Basic HTML Document

HTML stands for HyperText Markup Language. It’s a type of text document, where text is ‘marked

up’ by using special tags that inform a program that reads the text in how to render the text.

Typically that program is a Web Browser such as Internet Explorer, FireFox, Opera or Chrome.

Here’s an example of a very simple HTML document

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title>My First HTML Page</title> </head>
    <body>
        My text goes here.
    </body>
    </html>

For such more Blogs kindly visit to http://findnerd.com/NerdDigest

Wednesday 29 April 2015

Simple responsive menu using css3

 Hello readers !
This blog is about how to make a simple navigation menu .
First of all you need an unorder listing(ul-li) in html page as I have taken in example below.
Now remember you also need an anchor tag after list.
The anchor tag will not show in full width ,it works only when you decrease your view screen size.

After this we come on css.
Here we define all classes with their attributes. Also you can manage media screen width as per your needs.

Now the last and important step you need add javascript to hide and show last anchor tag.
Hope It will help you.
Note:- You have to include jquery library aslo.
<-- Html -->
  1. <nav class="clearfix">
  2. <ul class="clearfix">
  3. <li><a href="#">Nav Tital</a></li>
  4. <li><a href="#">Nav Tital</a></li>
  5. <li><a href="#">Nav Tital</a></li>
  6. <li><a href="#">Nav Tital</a></li>
  7. <li><a href="#">Nav Tital</a></li>
  8. <li><a href="#">Nav Tital</a></li>
  9. </ul>
  10. <a href="#" id="gear">Navigation</a>
  11. </nav>
<--css-->
  1. * {
  2. margin: 0px;
  3. text-decoration: none;
  4. padding: 0px
  5. }
  6. .clearfix:before, .clearfix:after {
  7. content: " ";
  8. display: table;
  9. }
  10. .clearfix:after {
  11. clear: both;
  12. }
  13. .clearfix {
  14. *zoom: 1;
  15. }
  16. body {
  17. background: #e5e5e5;
  18. font-family: Arial, sans-serif;
  19. }
  20. nav {
  21. height: 40px;
  22. background: #999;
  23. font-size: 13px;
  24. position: relative;
  25. font-weight: bold;
  26. }
  27. nav ul {
  28. margin: 0 auto;
  29. width: 600px;
  30. }
  31. nav li {
  32. display: inline;
  33. float: left;
  34. }
  35. nav a {
  36. color: #fff;
  37. display: inline-block;
  38. width: 100px;
  39. text-align: center;
  40. line-height: 40px;
  41. }
  42. nav li a {
  43. border-right: 1px solid #333;
  44. box-sizing: border-box;
  45. -moz-box-sizing: border-box;
  46. -webkit-box-sizing: border-box;
  47. }
  48. nav li:last-child a {
  49. border-right: 0;
  50. }
  51. nav a:hover, nav a:active {
  52. background: #666666;
  53. }
  54. nav a#gear {
  55. display: none;
  56. }
  57. @media screen and (max-width:599px) {
  58. nav {
  59. height: auto;
  60. }
  61. nav ul {
  62. width: 100%;
  63. display: block;
  64. height: auto;
  65. }
  66. nav li {
  67. width: 50%;
  68. float: left;
  69. position: relative;
  70. }
  71. nav li a {
  72. border-bottom: 1px solid #333333;
  73. border-right: 1px solid #333333;
  74. }
  75. nav a {
  76. text-align: left;
  77. width: 100%;
  78. text-indent: 25px;
  79. }
  80. }
  81. @media only screen and (max-width : 479px) {
  82. nav {
  83. border-bottom: 0;
  84. }
  85. nav ul {
  86. display: none;
  87. height: auto;
  88. }
  89. nav a#gear {
  90. display: block;
  91. background-color: #222;
  92. width: 100%;
  93. position: relative;
  94. }
  95. nav a#gear:after {
  96. content: "";
  97. background: url('navigationICON.png') no-repeat; /* This is the path of image */
  98. width: 30px;
  99. height: 30px;
  100. display: inline-block;
  101. position: absolute;
  102. right: 15px;
  103. top: 10px;
  104. }
  105. }
  106. @media only screen and (max-width : 320px) {
  107. nav li {
  108. display: block;
  109. float: none;
  110. width: 100%;
  111. }
  112. nav li a {
  113. border-bottom: 1px solid #333;
  114. }
  115. }
<--Script-->
  1. <script>
  2. $(function() {
  3. var gear = $('#gear');
  4. menu = $('nav ul');
  5. menuHeight = menu.height();
  6. $(gear).on('click', function(e) {
  7. e.preventDefault();
  8. menu.slideToggle();
  9. });
  10. });
  11. </script>
You have to include this :-

  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Simple Cakephp Pagination


Cakephp provides a quick an easy way to paginate data.
In the controller we start by creating the pagination condition as given below :
  1. public $paginate = array(
  2. 'limit' => 10,
  3. 'order' => array(
  4. 'Model.fieldname' => 'asc'
  5. )
  6. );
  7. public function listdetails(){
  8. $variable = $this->paginate("Model", array('Model.fieldname' =>'1'));
  9. }

Write the following code in the view where pagination has to be displayed here the view name is listdetails.ctp
  1. <?php
  2. echo $this->paginator->prev('<<Previous', null, null, null);
  3. echo $this->paginator->numbers();echo "&nbsp;|";
  4. echo $this->paginator->next('Next>>', null, null, null);
  5. ?>

For such more Blogs you can visit to http://findnerd.com/NerdDigest


Tuesday 28 April 2015

How to make a responsive table using css


In this blog i'll show how can you make responsive table. To make a table responsive first step is to know "nth-of-type" , that is a selector of css3 you can see that in css as i explain it ( In css - line 50 ), now we will make a table 

--Html--
  1. <div>
  2. <table width="100%" border="1">
  3. <thead>
  4. <tr>
  5. <th>Item Name</th>
  6. <th>Item Code</th>
  7. </tr>
  8. </thead>
  9. <tr>
  10. <td>Item 3</td>
  11. <td>001</td>
  12. </tr>
  13. <tr>
  14. <td>Item 4</td>
  15. <td>001</td>
  16. </tr>
  17. <tr>
  18. <td>Item 5</td>
  19. <td>004</td>
  20. </tr>
  21. </table>
  22. </div>

After complete table we come on css style sheet here i using css3 selector and for mobile screen i just change table heading text with selector and align all table using position and other . and It will works properly . 

--css--
  1. * {
  2. font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  3. font-size: 14px
  4. }
  5. div {
  6. width: 600px;
  7. margin: 0 auto
  8. }
  9. table {
  10. border-collapse: collapse;
  11. }
  12. td {
  13. padding: 4px
  14. }
  15. th {
  16. text-align: left;
  17. padding: 4px
  18. }
  19. @media only screen and (max-width : 600px) {
  20. div {
  21. width: 500px
  22. }
  23. table, thead, tbody, th, td, tr {
  24. display: block;
  25. }
  26. thead tr {
  27. position: absolute;
  28. top: -9999px;
  29. left: -9999px;
  30. }
  31. tr {
  32. border-bottom: 1px solid #CCC
  33. }
  34. tr:last-child {
  35. border-bottom: none
  36. }
  37. td {
  38. border: none;
  39. position: relative;
  40. padding-left: 30%;
  41. }
  42. td:before {
  43. position: absolute;
  44. top: 6px;
  45. left: 6px;
  46. width: 45%;
  47. padding-right: 10px;
  48. white-space: nowrap;
  49. }
  50. /*----CSS3 Selector-----*/
  51. td:nth-of-type(1):before {
  52. content: "Item Name";
  53. }
  54. td:nth-of-type(2):before {
  55. content: "Item Code";
  56. }
  57. }



For such more Blogs you can visit to http://findnerd.com/NerdDigest

Monday 27 April 2015

Why to prefer Magento over Zen cart

As eCommerce market in India is about to grow over $24 Billion USD by the end of 2015.To grab the opportunity of this growing market there are many eCommerce stores are coming up and each facilitating new features to make the user experience great. Which initiated a demand of eCommerce platforms between the developers which are more scalable for the development of the stores for their clients.
Magento is one such platform which has been enabling the developer to do provide all such features since its inception and giving a tough competition to its predecessors like Zen Cart .
Here are the list of inbuilt features that make you choose Magento over Zen Cart .
- Multi-store
- iPhone Optimized themes.
- Email Template
- On-click Install Module
- Product Comparison
- Bundled products
- Up sell Products
- Add to Wishlist
- Shipping to Multiple address
- Generating Multiple invoices .


For such more Blogs you can visit to http://findnerd.com/NerdDigest


Consulting - First step to Outsourced Product Development

John has been working in the HR industry for the last 20 years and has worked with various small to mid-size corporations in the US. For the last 6 months, John has been mulling over an idea for a software development product. He has been searching for the available products in the industry and found nothing that satisfies him. He can clearly see a gap and an opportunity for a great product. John discussed this idea with a friend Harry and he also seems to be very positive about it. John has no idea where to get this product developed or how to get it developed and what it will take. Harry has been working in a company which has outsourced a project and suggests John to try outsourcing the development of his idea. John likes it very much and started his search for the right company to develop his idea…

Outsourcing the development of a software product can be a great idea and it can yield excellent results in a very cost effective way. But the first step to get product development through outsourcing services is the key to success. This first step is consulting and finding the right partners for that. A great consulting partner can help you in many ways.

  1. Market research – When you thought about the idea, you must have done a preliminary market research. But a professional consulting partner can help you with a thorough research for your idea. He can help with competitor analysis, gap analysis, product positioning, target demographics and give you a clear picture of how useful your product can be.
  2. Converting an idea to a business case – Once you are convinced that your idea has the space and potential to fit in and do well, the next step is to give your idea a shape. The consultant can help put your idea on pen and paper. This gives a concrete shape to your idea. When it is written, the idea converts to a business case.
  3. Identifying the right channel to deliver your idea – Today’s world is full of channels through which you can reach to your customers. Your idea can be delivered through web, social channels like Facebook, applications on computers, mobiles etc. It is key to understand the strength of your idea and your target demographics. Based on that right delivery channel(s) need to be chosen for the idea. Your consultants will show you statistics for usage of different channels based on demographics (location, age). A professional business consultant will help define that. 
  4. Identifying the right technology – Once you know what needs to be developed and how it needs to be delivered, the next step is to choose the right technology platforms to develop it. Do you want to go for proprietary solutions or open source solutions? Which platforms, frameworks, programming languages, databases do you need? An experienced software solution consultancy partner will help you choose the best technology platforms to deliver your requirements through your chosen channels.
  5. Finding the experts – Now you know the skills that you require. The next step is to find and hire those skills. At this level, your consultant will act as an effective HR for you and get you the right people to do the job.
  6. Planning the execution – Now you have everything that you need to build the project. It is time to plan the execution. Today’s world does not want to wait for a year to get a taste of a new product. If you are going to take a year to bring your idea to world, someone else will get it out earlier. It is the age of MVP (Minimum Viable Product). Do not build too much. Do not try to give everything. Keep your idea lean and get it to the end users quick. Your users will tell you what they want most and build that. Give them what they want and not what you want to give them. Consultant will now put on the Product Manager’s hat and help you plan this.
  7. Marketing – You are not building the product for yourself. You got to sell it as well. Your consultancy partner’s job is not complete until he helps you with marketing your product as well. Product development is just a small part; the big part is how you market it. So, consulting is the first and key step to getting an outsourced product developed and it helps you get the right resources for not only development but getting your product out and LIVE!!!
Harry introduced John to his offshore partners, Evon Technologies. John is now a happy client of Evon Technologies and has been working with Evon for last 6 months. The first prototype of his idea was launched in 4 months time as an alpha release of the product. The Beta launch of the product is scheduled to happen in 1 month. Evon Technologies , which is a Web Design and Development Company in India is providing complete end to end consulting services to John as a one stop shop preventing him to run at multiple places to satisfy his wide range of needs. 


Web RTC : Strongest Api of HTML5

HTML 5 is rocking everywhere on the web.The key behind the HTML5 success is the set of

powerfull api it provides. These html5 api make a web app server independent in many ways.Such

an api or a set of api is webrtc. Web rtc is most powerfull thing html5 bought on the web

plateform .Web RTC is an open source .As internet has moved from the slower side to real time

environment .The need of comunication at real time felt so badly across the web ninjas.Web rtc

which means Real time communication make the dream of Real time video audio chat true.Web rtc

make the communication between two system without server dependency. The Web rtc have three

API currently. 1. getUserMedia

2.RTC Peer to Peer connection

3.RTC Data Channel

Get User Media : Getusermedia alowed the browser to access the system hardware without any

plugin . Which is the most powerfull ability browser ever got since NetScape time.

getusermedia ask the user permission for accessing the system hardware.Once the permission

granted by the user it uses audio video as an input device. GetUserMedia is currntly availble

in Google chrome 18 and above with flags , above Google Chrome 25 flagless ,firefox NIghtly

and Opera Stable .IE is still against it.getUserMedia allows browser to capture an image audio

or a video. In the era of HTML5 you can Play with these input.

    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||

navigator.mozGetUserMedia || navigator.msGetUserMedia;

    var videoTag = document.getElementById('videotag');

    if (navigator.getUserMedia) {
    navigator.getUserMedia({audio: true, video: true}, function(stream) { videoTag.src =

window.URL.createObjectURL(stream);
    }, errorCallback); } else {
    video.src = 'othervideo.mp4'; // fallback. }

I will discuss Peer to peer in next blog . Comments will be appreciated . Until then Adios

For such more Blogs you can visit to http://findnerd.com/NerdDigest

Sunday 26 April 2015

Programmatically create coupon codes in Magento

Create backup for your database and project directory 2.create a form to post the coupon code information. such as
  1. <div >
  2. <h2>Create New Coupons</h2>
  3. </div>
  4. <div >
  5. <div >
  6. <div >
  7. <dl >
  8. <dt><label for="discount">Discount Value Type</label></dt>
  9. <dd>
  10. <div >
  11. <select id="discount" name="discountType">
  12. <option value="by_percent">Percent</option>
  13. <option value="by_fixed">Fixed</option>
  14. </select></div>
  15. <div >
  16. <label for="value">value</label>
  17. <input id="spinner" name="discount_amount" value="">
  18. </div>
  19. <div ></div>
  20. </dd>
  21. <dt><label for="start_date">Start Date <a href="javascript:void(0)">?</a></label></dt>
  22. <dd>
  23. <div ><input id="datepicker" name="start_date" value=""></div>
  24. <!--input id="start_date" name="start_date" value=""></div-->
  25. <div >
  26. <label for="expire_date">Expiration Date</label>
  27. <input id="datepickerend" name="expire_date" value=" ">
  28. <!--input id="expire_date" name="expire_date" value=""-->
  29. </div>
  30. <div ></div>
  31. </dd>
  32. <dt><label for="coupon_code">Coupon Code <a href="javascript:void(0)">?</a></label></dt>
  33. <dd>
  34. <div >
  35. <input id="coupon_code" name="coupon_code" value=" "></div>
  36. <div ></div>
  37. </dd>
  38. <dt><label for="coupon_detail">Coupon Description <a href="javascript:void(0)">?</a></label></dt>
  39. <dd>
  40. <div ><textarea id="coupon_detail" name="coupon_detail"></textarea></div>
  41. <div ></div>
  42. </dd>
  43. </dl>
  44. </div>
  45. </div>
  46. <p><label for="discount_assign"> The Discount will be assigned on <a href="javascript:void(0)">?</a></label> &nbsp; <select id="discount_assign" name="discount_assign">
  47. <option value="0">Order Dishes Sum</option>
  48. <option value="1">Order Total Sum</option>
  49. </select></p>Coupon Limitations <a href="javascript:void(0)">?</a><p></p>
  50. <div >
  51. <ul >
  52. <li ># Times
  53. <div ><input name="times" value=" " id="spinner1"></div>
  54. </li>
  55. <li> # Times Per User
  56. <div ><input name="perUser" value=" " id="spinner2" "=""></div>
  57. </li>
  58. </ul>
  59. </div>
  60. </div>

3:create Action for post the form data such as
  1. <p><!--?php public function saveCouponAction(){</p-->
  2. </p><pre>$param=$this-&gt;getRequest()-&gt;getPost();
  3. $conditions_serialized = 'a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:1:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:13:"base_subtotal";s:8:"operator";s:2:"==";s:5:"value";s:2:"12";s:18:"is_value_processed";b:0;}}}';
  4. $data = unserialize($conditions_serialized);
  5. $data['conditions'][0]['value'] = $param['cart_value'];
  6. (string)$conditions_serialized = serialize($data);
  7. (string)$actions_serialized = 'a:6:{s:4:\"type\";s:40:\"salesrule/rule_condition_product_combine\";s:9:\"attribute\";N;s:8:\"operator\";N;s:5:\"value\";s:1:\"1\";s:18:\"is_value_processed\";N;s:10:\"aggregator\";s:3:\"all\";}';
  8. $data = array(
  9. 'product_ids' =&gt; null,
  10. 'name' =&gt;$param['coupon_code'],
  11. 'description' =&gt;$param['coupon_detail'],
  12. 'is_active' =&gt; 1,
  13. 'website_ids' =&gt; array(1),
  14. 'customer_group_ids' =&gt; array(1),
  15. 'coupon_type' =&gt; 2,
  16. 'coupon_code' =&gt;$param['coupon_code'],
  17. 'uses_per_coupon' =&gt;$param['times'],
  18. 'uses_per_customer' =&gt;$param['perUser'],
  19. 'from_date' =&gt;$param['start_date'],
  20. 'to_date' =&gt;$param['expire_date'],
  21. 'sort_order' =&gt; null,
  22. 'is_rss' =&gt; 1,
  23. 'conditions_serialized' =&gt; "'$conditions_serialized'",
  24. 'actions_serialized' =&gt; "'$actions_serialized'",
  25. 'simple_action' =&gt;$param['discountType'],
  26. 'discount_amount' =&gt;$param['discount_amount'],
  27. 'discount_qty' =&gt; 0,
  28. 'discount_step' =&gt; null,
  29. 'apply_to_shipping' =&gt; $param['discount_assign'],
  30. 'simple_free_shipping' =&gt; 0,
  31. 'stop_rules_processing' =&gt; 0,
  32. 'store_labels' =&gt; array($param['coupon_detail'])
  33. </pre>
  34. <p>);
  35. /<em>echo "</em></p><pre><em>";
  36. print_r($data);
  37. die();</em>/
  38. try{
  39. $model = Mage::getModel('salesrule/rule');
  40. $data = $this-&gt;<em>filterDates($data, array('from</em>date', 'to<em>date'));
  41. $validateResult = $model-&gt;validateData(new Varien</em>Object($data));
  42. if ($validateResult == true) {
  43. if (isset($data['simple<em>action']) &amp;&amp; $data['simple</em>action'] == 'by<em>percent'
  44. &amp;&amp; isset($data['discount</em>amount'])) {
  45. $data['discount<em>amount'] = min(100, $data['discount</em>amount']);
  46. }
  47. if (isset($data['rule']['conditions'])) {
  48. $data['conditions'] = $data['rule']['conditions'];
  49. }
  50. if (isset($data['rule']['actions'])) {
  51. $data['actions'] = $data['rule']['actions'];
  52. }
  53. unset($data['rule']);
  54. $model-&gt;loadPost($data);
  55. $model-&gt;save();
  56. $this-&gt;_redirect('manager/account/coupons');
  57. }
  58. }
  59. catch (Exception $e){
  60. echo $e-&gt;getMessage();
  61. }
  62. }<p></p>

4: check from admin panel or database table salesrule coupon has been added to your magento store.



For such more Blogs you can visit to http://findnerd.com/NerdDigest