PHP, Java and other languages provide replace all functionality to replace any character by any specific character. But REGEX is best method to replace or remove any specific value using pattern. Suppose, we have input string is

$xyz = "This is my best (friend)";
and we want to remove words from "()". So it so straight forward and simply:
"\\(.+?\\)"
That's it....

In my previous post [How to programmatically add shipment with a tracking number to any order : PART I], you found that how can we generate shipment for an order programmatically. Here we are going to learn next step to add tracking number with generated shipment. We are assuming that you are going to use UPS (United Parcel Service) shipping method for site order. Once you submitted your order to UPS, will get a tracking number from UPS dealer. And now you have to add this tracking number...

We are assuming that we have an order incremented id. and we want to make shipment for this order. Here also we are assuming that invoice has been generated for order already. so we are going to generate only shipment. $orderId = '1000001'; $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); Here we are checking the current status of order that it is processing or not. Why we are checking? Because we do not want to generate shipment for any order that has been...

I tried to wrote this code when I was working on a cron file for all orders. My client wants a cron file that get all orders information including all ordered item and their detail. First, I searched on google but I didn't found any exact solution then I tried below code: By below code I got all orders on site: $orders = Mage::getModel('sales/order')->getCollection(); Now, I am going to fetch all ordered items for each order. foreach ($orders as $order) { $items =...

Magento provides following types of page layout in default. 1column, 2columns-left, 2columns-right, 3columns, empty, and print. But sometimes we need to change design in layout and we do not want to affect on other pages. For example, we want to use different layout for all static pages. and we want to use 2columns-left layout style but do not want to change in existing layout. That time what we have to do? Yes, we can create our custom layout. To make your custom layout, follow...

Magento provides lot of inbuild functionalities. Using "protected function _prepareColumns()" function we can create or add new column to the grid. Like: protected function _prepareColumns() { $this->addColumn('first_name', array( 'header' => Mage::helper('custommodule')->__('First Name'), 'align' => 'left', 'width' => '50px', 'index' => 'first_name', )); $this->addColumn('last_name', array( 'header' => Mage::helper('custommodule')->__('Last...

Have you upgraded your magento version OR installed any module/extension manually? If you getting this error: "Fatal error: Call to a member function addFieldToFilter() on a non-object ......" after doing any step above then you have to following steps to solve: Step 1: Re-index the all tables. a) To re-index Go to your site admin panel. b) System > Index Management c) Select all rows and submit button with reindex selection in dropdown. Step 2: Clear all cache and session. a) To...

Today we are working on cron file that will call all model methods of my custom module. But we are getting error: "Magento: Fatal error: Call to a member function getModelInstance() on a non-object in appMage.php on line 141". when we are using: require_once 'app/Mage.php'; $customobj = Mage::getModel('custommodule/custommodule'); It was amazing for us that we developed many extension but never get such type of issue. What may be reason? Oooofff........hmmm.... Then we...

Sometimes we need to give free shipping on some specific conditions but we do not want to enable free shipping method. Then what to do? After did much R&D and read many blogs I found a solution. It was so simple, it is possible by shopping cart price rule. First disable to Free shipping method from Shipping Methods section. Then create a shopping cart price rule for free shipping by following steps: 1. Go to Promotions > Shopping Cart Price Rules. 2. Click on Add New Rule...

We can add or remove anythings in magento core files but it is not a perfect solution. To make a perfect solution, we are creating a small module. By this module you will able to add / remove navigation links from customer account dashboard. Firstly, we create a module XML file to access from local folder: Step1: Create a file "Nos_Navigation.xml" in app\etc\modules\ folder Step2: Put below code in this xml file true local ...

Magento comes with many folders and its structure is complex. In general, it is not easy to find the perfect file to edit for a specific section. Because there may be many folders with same name in different directories. you are thinking then What is template path hints? Template path hints is just a tags which provides a correct path to edit any section. It may be use for frontend or backend. To view the hints, you have to enable this functionality in the admin panel. default, it set...

In default magento setup, product rating is not showing on product detail page while in the demo you see that rating is showing. Don't worry about this. we show you how you can enable rating system by following below steps: 1. Log in to admin panel 2. Go to Catalog > Reviews and Ratings > Manage Ratings 3. You will see there are three attributes are showing. Means user can give rating on price basis, quality basis, or Value basis. Also you can add new attribute by pressing 'Add...

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data...

Magento provides log file to maintain each type of error on your application. By this you can add log error or exception to magento's system log file. Its very handy to view coding errors. Developing for Magento is often hard, especially since it’s not always possibly to have error reporting on (and even when it is on, its hard to find exactly what’s wrong!). There are some steps to manage log errors: Step-1: Go to Admin > Configuration > Developer > Log Settings > Enabled and set...

Zend provides JOIN, joinLeft, joinRight keywords to join two or multiple tables.  you can make an sql object by calling select function of current model by:

$select = $this->getDbTable()->select();
Use below line to use JOIN terms in your SQL:
$select->setIntegrityCheck(false);
By default its integrity value set to True and it do not allow to use join with multiple tables. We set to False and then we can use JOIN.

Zend provides a facility to delete a row from the database table using the delete() method. This method takes one argument, which is an SQL expression that is used in a WHERE clause, as criteria for the rows to delete. For example : $modelObj = new ModelName(); $where = $modelObj >getAdapter()->quoteInto('id = ?', '1235'); $modelObj >delete($where); The second argument can be an array of SQL expressions. The expressions are combined as Boolean terms using an AND operator. Since...

Today's market is based on 3D and most things are doing by jQuery or Javascript to make fast loading application. Opacity is a part of CSS to make transparent image without PNG format. To set the opacity property to an image you can use: .img_transparent_class{ opacity: 0.5; } But this line will suitable for some latest browsers and it will not show effects in some browsers like IE 7 and IE8, etc. To apply in all browsers you can follow: .img_transparent_class { /* IE 8 */ ...

Categories

Users who liked us on Facebook