Something very nice ..

11 04 2011

نہ گلہ ہے کوئی حالات سے نہ شکایتیں تیری ذات سے  …  خود ہی سارے ورق جُدا ہوئے میری زندگی کی کتاب سے






Delete test orders in Magento 1.4.x

7 11 2010

hay Friends,

Many of you must have noticed that Magento has brought much changes in it’s EAV based database structure in version Magento 1.4.x. Like they did for changes in order data storage, perhaps this decision is to reduce the over complex structrue.

When we are developing some Magento based project, we oftenly try to add test data to check whether everything is fine or not. Though we can delete this test data using delte option but if you added some test order then you are stucked as Magento don’t give any option to delete a record from Magento prompt. So solution in such cases is to go at database prompt and run queries to reset Magento. Following are few queries for the same purpose:

– Reset Magento TEST Data
SET FOREIGN_KEY_CHECKS=0;

– Reset dashboard search queries
TRUNCATE `catalogsearch_query`;
ALTER TABLE `catalogsearch_query` AUTO_INCREMENT=1;

– Reset sales order info
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

Hope this information was helping!





Magento :: get URL paths for skin, media, Js OR base URL

12 05 2010

hello friends,

If anyone of you facing problems to fetch the Magento URL paths of  skin, media, Js or simple base URL of Magento while customization/programming, then following lines should be helpful for you:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
//http://magento.demo/js/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
//http://magento.demo/index.php/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
//http://magento.demo/media/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
//http://magento.demo/skin/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
//http://magento.demo/

Enjoy!





Magento :: add or remove javascript files to your template

25 03 2010

Following  lines will be helping for you if you’r trying to add some javascript file to your custom theme. As per your requirements, you’ll need to see in which layout file you want to call your js file and simply put this line there:
<action method=”addItem”><type>skin_js</type><name>js/product.js</name></action>

Above line will try to find the product.js file under /skin/frontend/default/Your_Theme/js /product.js

Similarly you can remove a default javascript file by putting this line in your layout file:

<action method=”removeItem”>   <type>js</type>   <name>varien/product.js</name>   <params />   </action>

Hope this will be helping someone for fighting against Magento.





J2T Points & Rewards :: Step by step configurations

16 03 2010

hello,

“J2T Points & Rewards” is a big and FREe extension for Magento based e-commerce stores where Discounts are rewarded to customers on the basis of amount that they spent to buy from the store. In short, this is a Points and Reward system for a magento based store.

I really faced hard time to see some step by step manual to configure this extension but got no luck. Eventually i was able to configure it successfully with the help of some community mates (thanks to them) so thought to share. Here it is:

Step1: Disable your Cache.
Step2: Make sure you have copied the template and layout files of this extension under the active template of store.

Step3: Go in Reward points > Configurations and make following settings (you may set it according to your business logic too):
money to obtain: 1
points to obtain 1: 100
apply points by step: no
leave step value blank
use max points: no
round up points: no
coupon code restriction: yes
apply store scope: yes

Step4: Go Promotions –> Shopping cart price rules and add a shopping cart price rule with following settings:
rule name: points
customer group: general
coupon code: points
under action tab have the “fixed amount discount for entire cart”

Step4: Go catalog –> attributes –> manage attribute
create ‘reward_points’
scope: global
apply to: all product types
Use for Price Rule Conditions: yes
Allow HTML-tags on Front-end: yes

That’s it! After these settings are done, you’ll be able to see these effects:

– Reward points section is being shown in Customer Account area.
– Logged in User is given an option to redeem the points on shopping cart page.
– discount is applied on shopping cart

Hope it will be helping for someone.





Magento::calling a static block in your template file (.phtml)

17 02 2010

To call a static block in Magento, Following single line will solve your problem,

<?php getLayout()->createBlock('cms/block')->setBlockId('my_static_block_name')->toHtml() ?>

Definitely we’ll write this line in some .phtml file for which you want to call this block …

Hope this tip will be helping for someone ;)





PHP :: remove special characters from a string

15 12 2009

This could be just a quick and easy help for someone who is wishing to remove special characters from some string OR wishing to just keep alpha numeric characters in the string. So here is the Regular expression for that:

preg_replace('/[^a-z0-9]/i', '_', $string)





Most useful PHP Libraries

26 11 2009

Did you faced such situation that you need to complete a project on early basis and you waste your big time to search for your required libraries and then knowing how to go for your integration? Yes .. such days often come in some software developer’s life ..

Open source matters! so PHP is at top for helping you by providing such a huge community where you get great “plug and play” stuff for attaining quicknees in your work.
In same respect, Today i am gonna share with you a list of 20 Most Useful PHP libraries about which every PHP developer must now. So here they are:

Charting Library

GD library may help you to create a good but simple chart but for complex charts, here are some great libraries:

  1. pChart – a PHP class to build charts.
  2. Libchart – Simple PHP chart drawing library.
  3. JpGraph – Object-oriented graph creating library for PHP.
  4. Open Flash Chart – Flash based charting library.

RSS Parser Library

Parsing a RSS gets painful sometime, so why don’t you prefer to use any of following libraries and enjoy???

  1. MagpieRSS – RSS for PHP.
  2. SimplePie – Super-fast, easy-to-use, RSS and Atom feed parsing in PHP.

Thumbnail Generator

Good way for generating Thumbnails.

  1. phpThumb – The PHP thumbnail creator.

Payment

Playing with an e-commerce site? Need payment solution?. Let this library help you ;)

  1. PHP Payment Library – PHP Payment Library for Paypal, Authorize.net and 2Checkout (2CO)

OpenID

Just in case you need to implement OpenID to your project.

  1. PHP-OpenID – OpenID implementation in PHP.

Database Abstraction/ORM

 These library let you smile more while writting SQL quries.

  1. ADOdb – Database abstraction library for PHP.
  2. Doctrine – Object relational mapper (ORM) for PHP 5.2.3+ that sits on top of a powerful database abstraction layer (DBAL).
  3. Propel – Object-Relational Mapping framework for PHP5
  4. Outlet – an Open source object-to-relational mapping tool for PHP.

PDF Generator

  1. FPDF – PHP class which allows to generate PDF files with pure PHP.

Excel

Enjoy if you need to generate your report in Excel file while using these libraries .

  1. php-excel – Very simple library for generating excel documents from php on-the-fly.
  2. PHP Excel Reader – Parse and retrieve information from XLS files.

E-Mail

Don’t like PHP mail function? Give a chance to any of these libraries:

  1. Swift Mailer – Free Feature-rich PHP Mailer.
  2. PHPMailer - Powerful email transport class with a big features and small footprint.

Unit Testing

For Test-driven development lover, these library will help great.

  1. SimpleTest – PHP unit test and web test framework.
  2. PHPUnit – Member of the xUnit family of testing frameworks and provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results.

Hope these libraries will make your programming life more easier and happy :)

Happy Coding ;)





its been long time …

20 11 2009

It’s been long time that i got chance to write some thing on my blog.

Sometimes, Life gets too busy and even you don’t find time for yourself but … We spend the time somehow ..

Hopefully you’ll see further informative and much logical stuff from my side (this wasn’t an announcement but a humble decision :) ).

See ya ;)





css tip : set margin parameters

31 10 2009

if you get confuse and feel hard to remember the parameter sequence for ‘margin’ tag in css then just bookmark the url of my this post :)

General Format:

margin:Toppx Rightpx Bottompx Leftpx

 

Example:

<div style=” margin:14px 10px 7px 16px;”>
This inline css code will make this div to produce margin: 14px at top, 10px at right, 7px at bottom and 16px at left

Hope this will help someone ;)








Follow

Get every new post delivered to your Inbox.