[Magento] How to add additional sort by : Newest product and make the default sort order direction to DESC for the product listing.

 

1) Goto Catalog->Manage Attributes->Set Product as New from Date attribute

2) Mark it as Yes for sorting in product listing page

The main issue for the new product will not work even though you have set it up as above.

As a default, it will be selected for the newest but the output might be  shown from the oldest.

Change Direction from Ascending to Descending:

To change default product direction from ascending to descending-

go: app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

Now Open the Toolbar.php file and find out the following line (Line no. 119 in 1.5):

  1. protected $_direction = ‘asc’;

Now Change above code by the following code:

  1. protected $_direction = ‘desc’;

After doing this, refresh your category page. If not any change you must clear cache and Reindex by go: System -> index Management from Backend now select all checkbox.

Then Select ‘Reindex Data’ in Actions field after that click on Submit button from right top.

Now your product will show by descending direction as default in Category page.

[Magento] Adding Link to Top Links Section in Magento

Please try to open the file “app/design/frontend/default/ves_fashion/layout/local.xml”. Then add the code:

 

<default>
<reference name=”top.links”>
<action method=”addLink” translate=”label title”>
<label>Contact Us</label>
<url>contacts</url>
<title>Contact Us</title>
<prepare>true</prepare>
<position>20</position>
</action>
</reference>
</default>


	

How to remove ask.com search new tab from google browser

Ask.com is sneaking around to install its main page to chrome browser so that it can be the default new tab page or default search engine. This video wil show you how to remove it.

Many people start with  Google search page of chrome from in many different places such as desktop system,

android smart phone, tablet, and so on.  What I meant is  you are expected to see the google search   page based on opening new tab or chrome browser.

 

ask.com search new tab

 

ask.com search new tab

However, it might be a virus or something you have committed to install ask.com as a default page while you are installing a software to your device.

In order to remove it, you have to uninstall it from the control panel.

1. start menu -> control panel -> Programs ( uninstall) : You will see the ask.com from the installed programs and select it and click the uninstall.

2. it might not uninstall it easily, since the Chrome processes are running in the background.  In this case, you have to go task manager and find all chrome names and stop the processes. 

3. then go to the tools from the Chrome browse and open the extensions. If there is any ask.com existed, then remove it too.

 

chrome_tools

 

4. the last step is go to settings of Chrome browser and check whether the default search engine is google or not. If it is the ask.com, it has to be removed too and set google.com as the default.

How to replace batteries for remote car access key?

The recent manufactured cars would not use conventional keys to open the door. It will need to have a remote access key. While it is providing easy access to a wheel, it would also provide you a trouble to get in.

What if the remote access key lost its power, then the remote key is no use. The life time of battery is around 2-3 years and the smart car will indicate you about the low battery of remote access key. Then, the easy and simple way is bring your car to service center or dealer shop to replace old batteries in order to avoid further troubles. It would cost you around $20-$30 from professional service.  But if you are brave enough to open remote access key, then it would cost you only few $.

First, open the key or check the owner’s manual to know correct type of battery.

Second, buy a battery from ebay or any online shopping mall to save money. This is painful to wait but will save you few more bucks.

Third, replace a battery with new one and try it on. You should not see the warning sign or indication of low battery of remote access key.

Simple and Easy to replace batteries for the remote car access key!

Capture a signature image, create a PDF from HTML, and send an email with PDF file on the fly

Capture a signature image, create a  HTML with signature image, convert HTML to PDF file,  and send an email with PDF file.

The title might give you headache from the starting point but once you know each details as my instruction, it will be simple and easy to implement it.

The requirements from my client was quite a simple as below;

1. have customer read agreement contents and sign it on any digital equipment or device.

2. get a copy of signature and create a PDF.

3. Send this PDF file to customer through email.

As you can see above requirements, it sounds not that complicate.

So, I have designed a simple application to fulfill these requirements through following technologies.

1. AngularJS

2. RESTful API in Java using JAX-RS and Jersey.

3.Itext with Flying source + rendering tool

4. Sendgrid email

 

First, The Angular JS framework is providing  lots of breathing room without worrying about structuring whole project. It is simple and easy to start.

Second. the Jersey restful webservice is another simple set to connect to database and utilize the JSON type of data. If you would like to design Backend service, this will be the simple and quick answer to everybody.

Third,  Itext with flying source is providing good library to convert from HTML to PDF. It was bit picky to make right format of HTML in order to be converted properly.

Finally, the sendgrid library is providing many headache to configure the mail server and simple to use too.

The below are details and should know for implementing this.

1. download the AngularJS + Java backbone RESTful API in Java using JAX-RS and Jersey from this site. (http://coenraets.org/blog/2012/02/sample-application-with-angular-js/)

 

2. Setup a Eclipse project  that should have connection to tomcat server

 

 

 

 

eclipse settting
eclipse settting

 

3. Important things to know at the Angularjs setting;

– app.js :  declare the overall app for service, controller, and routing

ex.)

angular.module(‘king’, [‘king.filters’, ‘king.directives’,’king.services.signature’,’king.services.cashsignature’]).

$routeProvider.when(‘/search’, {templateUrl: ‘partials/search.html’, controller: SearchCtrl});

 

– controller.js : handle events from page

ex.)

function MainCtrl($rootScope,$scope) {

window.location = “#/search”;
$rootScope.$apply();

}

– service.jsp : connect to the backend service

ex.)

angular.module(‘king.services.signature’, [‘ngResource’]).
factory(‘Signature’, function($resource){
return $resource(‘api/signature/:rewardcardId’, {}, {
query: {method:’GET’, params:{rewardcardId:’signature’}, isArray:false},
update: {method:’PUT’, params:{rewardcardId:’signature’}, isArray:false}
});
});

 

4. The web.xml file that should be set asbelow example;

 

<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.bm.web.java</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>

 

5. For the signautre it will need jSignature.js library. The code example is below;

– ex.) HTML code;

<!– This will be the area of sign –>
<div id=”signature”></div>
</div>
<div id=”tools”></div>

– ex.) controller.js;

function SignCtrl($rootScope,$scope,CashSignature,Signature) {
console.log(” SignCtrl is invoked”);
$scope.signature =CashSignature.getSign();

(function($) {
var topics = {};
$.publish = function(topic, args) {
if (topics[topic]) {
var currentTopic = topics[topic],
args = args || {};

for (var i = 0, j = currentTopic.length; i < j; i++) {
currentTopic[i].call($, args);
}
}
};
$.subscribe = function(topic, callback) {
if (!topics[topic]) {
topics[topic] = [];
}
topics[topic].push(callback);
return {
“topic”: topic,
“callback”: callback
};
};
$.unsubscribe = function(handle) {
var topic = handle.topic;
if (topics[topic]) {
var currentTopic = topics[topic];

for (var i = 0, j = currentTopic.length; i < j; i++) {
if (currentTopic[i] === handle.callback) {
currentTopic.splice(i, 1);
}
}
}
};
})(jQuery);
$(document).ready(function() {

// This is the part where jSignature is initialized.
var $sigdiv = $(“#signature”).jSignature({‘UndoButton’:false})

// All the code below is just code driving the demo.
, $tools = $(‘#tools’)
, $extraarea = $(‘#displayarea’)
, pubsubprefix = ‘jSignature.demo.’

$(‘<span><b>Please confirm your sign by clicking this Sign button: </b></span><input type=”button” value=”SIGN NOW” >’).bind(‘click’, function(e){
var data = $sigdiv.jSignature(‘getData’,’image’)
var signature = CashSignature.getSign();
signature.signString=data;
console.log(“signature is processing ” );
//updateSignature($rootScope,$scope,signature,CashSignature.getSign().customerid);
signature.$update({ customerid: signature.customerid});

console.log(” SignCtrl is invoked and will save data :”)
window.location = “#/search”;
//}
}).appendTo($tools)

$(‘<span><b> or: </b></span><input type=”button” value=”Reset”>’).bind(‘click’, function(e){
$sigdiv.jSignature(‘reset’)
}).appendTo($tools)

if (Modernizr.touch){
$(‘#scrollgrabber’).height($(‘#content’).height())
}

})
}

6. creating sign image from byte array

ex.)

//String imagefilename=Utils.getTempSignSlot();
String imagefilename=”sign_”+customerID+”.png”;
System.out.println(“imagefilename ” + imagefilename);
try {

byte[] bytearray = Base64.decode(sign);

BufferedImage imag=ImageIO.read(new ByteArrayInputStream(bytearray));
ImageIO.write(imag, “png”, new File(Utils.getsignImagePath(),imagefilename));
} catch (Exception e ){
System.err.println(“Exception at “+ e.getMessage());
}

return imagefilename;

 

7. convert HTL to PDF example code

ex.

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;

import org.xhtmlrenderer.pdf.ITextRenderer;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.lowagie.text.DocumentException;

public class ReleaseSignedPDF {
public static void createSignedPDF (Signature sig, String FileName)
throws IOException, DocumentException {

String localtmphtmlpath = Utils.getTempHtmlServerPath()+”/tmphtml/” + FileName;
System.out.println(“URL is ” + localtmphtmlpath);

WebClient webClient = new WebClient();

HtmlPage page = webClient.getPage(localtmphtmlpath);

OutputStream os = null;
try{
os = new FileOutputStream(Utils.getTempPDFPath()+ “/”+sig.getName().trim().replaceAll(” “, “_”)+ “_”+sig.getBarcode() +”_signed.pdf”);

ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(page,null);
renderer.layout();
renderer.createPDF(os);
} finally{
if(os != null) os.close();
}

}

}

8.send mail with PDF file;

ex.)

import com.github.sendgrid.SendGrid;

public class SendMail {

public static void sendMail(Signature sig)
{
try {
boolean noemailflag=false;

SendGrid sendgrid = new SendGrid(Utils.getEmailUserID(), Utils.getEmailPassword());

if(sig.getEmail() != null || !sig.getEmail().equals(“”)){
sendgrid.addTo(sig.getEmail());
sendgrid.addTo(Utils.getEmailAddTo());

}
else
noemailflag=true;

sendgrid.setFrom(Utils.getEmailAddTo());
sendgrid.setFromName(Utils.getEmailFromName());
sendgrid.setSubject(Utils.getEmailSubject());
sendgrid.setText(Utils.getEmailText());
sendgrid.addFile(new File(Utils.getTempPDFPath()+ “/”+sig.getName().trim().replaceAll(” “, “_”)+ “_”+sig.getBarcode() +”_signed.pdf”));
sendgrid.send();

}catch (Exception mex) {
mex.printStackTrace();
System.err.println(“Send MAil has an exception “+ mex.getMessage());
}
}

}

 

How to Replace Toner Cartridges in a HP LaserJet CP2025

Clever Supplies brand products are made in the USA! Why pay more for cheaper product with a high defective rate? You will end up having to send it back to the manufacturer. Your time is valuable. Get a quality product that you KNOW will work. Purchase the Clever Supplies Compatible for HP CP2025 (Q3960A), Black and experience the difference! All Clever Supplies brand products are backed by ‘100% Quality Satisfaction’ 1 year warranty against defects in materials and workmanship for all toner products. Free tech support for any problems for all Clever Supplies brand products.

The use of Clever Supplies brand replacement laser toner cartridges and supplies does not void printer warranty. Premium Quality Replacement Toner Cartridge is made by ISO9001 Certified Factory to Meet or Exceed OEM Standards. These units are manufactured 100% brand new with all new parts including OPC drums, wiper blades, a smart chip and other internal parts, they are an economical alternative to expensive OEM CC530A Compatible Toner Cartridges. The Compatible Toner Cartridges will produce the same amount of page yield as an OEM cartridge would.

This is a Compatible for HP CP2025 Toner Cartridges Black guaranteed to perform with HP Laser Printers. It replaces the original HP CP2025 Toner Cartridges Black. The compatible replacement for Q3960A. The use of compatible replacement Cartridges and supplies does not void Printer Warranty. Our Compatible for Q3960A. Cartridge is a replacement for OEM HP . We offer a 100% Quality Satisfaction Guarantee on our Compatible for Q3960A Laser Toner Cartridges and supplies.

For use in the following printers: COLOR LASERJET CM2320, COLOR LASERJET CM2320N, COLOR LASERJET CM2320NF, COLOR LASERJET CM2320FXI, COLOR LASERJET CP2025, COLOR LASERJET CP2025N, COLOR LASERJET CP2025DN, COLOR LASERJET CP2025X, COLOR LASERJET CP2020, COLOR LASERJET CM2320MFP, COLOR LASERJET CP2026

Remanufactured Hewlett Packard (HP) Color LaserJet CP2025 Set of 3 Color Toner Cartridges: 1 of each CC531A Cyan, CC533A Magenta, and CC532A Yellow

error: Content is protected !!