sortableRows with TbExtendedGridView in Yiibooster

After spending a fews hours trying to dig the widget classes and functions , my sortable rows were not being saved and the db table column values were not updating , I googled alot and asked in the mIRC channel aswell, and after alooooot of hair pulling i found the solution and am writing this post, just in case somebody else is looking for a solution !

  • Create new column in your db table with name “sort_order” type INT
  • Make sure the first value of column “sort_order” is NOT a “Zero” else it wont work !
  • Update Model with Gii or manually add the new attribute.
  • Update form or grid view files to show new column.
  • Update in your controller Access Rules, else you will get the following error : Error 403: You are not authorized to perform this action.

e.g

	public function accessRules()
    {
        return array(
        array('allow',  // allow all users to perform 'index' and 'view' actions
        'actions'=>array('index','view','sortable'),
        'users'=>array('*'),
        ),

Now our friends at YiiBooster brought us a Awesome class to handle new row postion from view to update the column field with new positions in the database table, so your sorted rows will be saved on refresh !

  • We need to add a custom function as following in our controller
	/*
     * Attaching Model to Sorting Component
     */
    public function actions()
    {
        return array(
            'sortable' => array(
                'class' => 'bootstrap.actions.TbSortableAction',
                'modelName' => 'Coreg'
            ),
        );
    }
  • Moving to the view file your TbExtendedGridView widget should look like the following .
<!--?php $this--->widget('bootstrap.widgets.TbExtendedGridView', array(
    'sortableRows'=>true,
    'sortableAttribute' => 'sort_order',
    'sortableAjaxSave' => true,
    'sortableAction' => 'coreg/sortable',		// Custom action we added in our controller to handle updates
    'afterSortableUpdate' => 'js:function(){}',
    'responsiveTable' => true,      		// Mobile Optimize the table
	........
  • Lastly modify your models search() function to Sort by the new column
public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.
		$criteria=new CDbCriteria;

        $criteria->compare('sort_order',$this->sort_order);

        return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
            'sort'=>array(
                'defaultOrder'=>'sort_order ASC',
            ),
		));
	} 	

Leave a comment below if you are still having a problem or ask in #yii at freenode irc network.

Writing Web Applications Using YiiBoilerplate

While making websites with Yii framework for medium-sized businesses over and over again, we adopted a standard way of structuring the project over time. It was initially based on the following premises: Separate public (“frontend”) and administrator’s (“backend”) sides to different domains for security purposes. Have an application configuration modular, so we can have parts […]

By Mark Safronov While making websites with Yii framework for medium-sized businesses over and over again, we adopted a standard way of structuring the project over time. It was initially based on the following premises: Separate public (“frontend”) and administrator’s (“backend”) sides to different domains for security purposes. Have an application configuration modular, so we can have parts […]

Source: CleverTech DevBlog

    

Latest and Stable Yii Framework and Bootstrap solutions

After having tested and used almost all different versions of Yii and Bootstrap integrations…,i can say that following are two most stable options for anyone considering to use twitter bootstrap with yii framework in terms of support, updates and solutions.

YiiBooster

is a widget toolkit for Yii web framework. Its main purpose is to ease building UI in Yii-based web applications utilizing the beauty of Twitter Bootstrap and several other great UI plugins developed over time by the community.

Twitter Bootstrap wrapping is based over the excellent job of Christoffer Niska called Yii-Bootstrap.

Widgets at a glance

Overall, the following is included in YiiBooster:

Get started by using the following tutorial http://yii-booster.clevertech.biz/getting-started.html

OR

 

YiiBoilerplate

Structure for enterprise-grade websites for Yii framework. Already thought-out.

It was initially based on the following premises:

  1. Separate public (“frontend”) and administrator’s (“backend”) sides to different domains for security purposes.
  2. Have an application configuration modular, so we can have parts of it committed to VCS repository for everyone and parts of it being crafted for every specific developer.

This two premises have lead to significant changes from the traditional project structure, described in Yii tutorial. It even affected the terminology, creating two new terms “entry point” and “environment”..

Overview

YiiBoilerplate was designed for medium-sized Yii-based web applications of any kind. By “meduim-sized” we mean 10 to 100 unique routes. Again, it has a harness to support two-tier test-first development, with Behat for end-to-end acceptance tests and PHPUnit for both pure unit tests and integration tests.

Basically, YiiBoilerplate is a bunch of files and folders you commit to your VCS repo as your “initial commit”, then start working for real. It consists of a proof-of-concept website, having one-page blank frontend and an admin side with rudimentary UI and a password-based authentication already done.

You can read the whole “table of contents” for the various directories of the YiiBoilerplate in README.md files inside that directories.

Top-level Directories

  1. backendBackend entry point, expected to be your “admin side” of the application.
  2. binBinaries for you to use, including yiic, phing, phpunit and such. Note that while most of binaries are Composer-installed, yiic and selenium launchers are hand-crafted and not supposed to be removed/changed.
  3. carcassConfiguration for various 3rd-party tools used in project harness, including Vagrant stuff and code style definition for CodeSniffer.
  4. commonThis folder is structured similarly to the traditional protected folder in autogenerated Yii application. You are expected to place the code global to all entry points in common. Backend-, frontend-, and console-specific stuff should go to backend, frontend and console dirs, respectively.
  5. consoleConsole entry point, reachable by yiic console runner. Most important stuff here is your migrations, inside console/migrations subfolder.
  6. frontendFrontend entry point, expected to be public side of your application.
  7. reportsAll project status reports from various code quality tools will be placed in here. Documentation from APIGen, too. You will not see this directory initially, it’s auto-generated when needed.
  8. testsYour test harness is here. See details in the README.md there.
  9. vendorAll third-party dependencies are installed by Composer in here, even Selenium. You will not see this directory initially, it’s auto-generated when needed.

Successful REST API Design

Lately the REST “word” is being thrown into the digital wind very often, and often enough, it’s not being fully understood, so as the concept gets twisted into incomplete versions of it, the products that use it end up missing some of the good parts. In this post, we’ll try to give a complete look […]

By Fernando Doglio Lately the REST “word” is being thrown into the digital wind very often, and often enough, it’s not being fully understood, so as the concept gets twisted into incomplete versions of it, the products that use it end up missing some of the good parts. In this post, we’ll try to give a complete look […]

Source: CleverTech DevBlog

    

Rapid project development with YiiBooster

There is always long way from idea of web project to the real running site. At the beginning one has to be able to specify the goals project is going to hit. When we have this defined and we are still sure the idea has chance to be succesfull, that there is a place on […]

By tomas hnilica There is always long way from idea of web project to the real running site. At the beginning one has to be able to specify the goals project is going to hit. When we have this defined and we are still sure the idea has chance to be succesfull, that there is a place on […]

Source: CleverTech DevBlog

    

Builtin Angular Filters

What is an Angular filter? Angular comes with several convenient tags to help us modify code in our templates. Here is the basic syntax for filter: {{ expression | filter }} expression is the data to be filtered upon filter is the name of the filter used to modify the expression Filters […]

By Simon W. Jackson What is an Angular filter? Angular comes with several convenient tags to help us modify code in our templates. Here is the basic syntax for filter: {{ expression | filter }} expression is the data to be filtered upon filter is the name of the filter used to modify the expression Filters […]

Source: CleverTech DevBlog

    

Moving Magento store to another server

Custom Magento stores are probably the most complex pieces of web related software out there, and most of the time developers are happy when they come to a point where things (mostly) work. You can imagine the horror Magento developer is up against, when a few weeks before holiday season, Google Analytics gives indication that current hardware infrastructure just won’t cut it. In this article I’ll do my best to guide you trough process of moving your Magento code, files and database to another server. Additionally, I’ll give you some pointers regarding DNS changes required for pointing your domain to another IP address.

By Marko Martinovic

Custom Magento stores are probably the most complex pieces of web related software out there, and most of the time developers are happy when they come to a point where things (mostly) work. You can imagine the horror Magento developer is up against, when a few weeks before holiday season, Google Analytics gives indication that current hardware infrastructure just won’t cut it. In this article I’ll do my best to guide you trough process of moving your Magento code, files and database to another server. Additionally, I’ll give you some pointers regarding DNS changes required for pointing your domain to another IP address.

Preparation for transfer

The curse of developing ecommerce sites is that downtime can be easily expressed in terms of lost revenue, and this is something we developers must be aware of. With process of moving any site to new server there is a portion of downtime caused by changing IP address in the context of DNS changes propagation. This downtime is unavoidable and not directly under our control, so we really want to minimize amount of downtime caused by moving code and database to another server. The key to achieving fast and effective Magento transfer is in preparation.

Establishing connectivity

First step to our goal is tweaking OpenSSH on both source and destination server to allow secure data transfers without requiring user account passwords. We will accomplish this using Public-Key authentication. Designated user accounts on both of your servers most probably already have private-public key pair generated. If .ssh directory of user account is empty or non existent, you must generate private-public key pairs your self. Creating unencrypted key pair (password-less) is something that isn’t generally recommended but for sake of simplicity this is what we will do here using ssh-keygen command. This should be executed for every server without existing private-public key pair:

ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa

At this point designated user accounts at both servers should have .ssh directory under their home and inside two files named id_rsa and id_rsa.pub. The first file is the private key (keep it private) and the second file is the public key (feel free to share because it can only be used to grant your server access to outside resources). To achieve password-less connectivity between your machines you must do two things. First you must install each server’s public key to every other remote machine’s authorized_keys file. You can use ssh-copy-id command to do so:

# Execute from your source server
ssh-copy-id [email protected]

# Execute from your destination server
ssh-copy-id [email protected]

Second thing you must take care of is set secure permissions for .ssh directories as well as all parent directories for .ssh (usually only /home):

# Remove write permission from home for group and others
chmod go-w ~/
# Secure permissions for .ssh and private key
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
# A little less secure permissions for public key
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts

If you can now connect trough ssh from your source server to destination server and vice versa without being asked for password, you did good and you can proceed. If this isn’t the case, then retrace your steps, especially the permissions part.

Server configuration

This is a really broad field that largely depends on the Linux distribution in question, web server of choice (Apache, Nginx), and infrastructure configuration (number of servers involved). Luckily this is something that should be done by your client’s hosting company (sadly this wasn’t the case when this procedure was created, expect more about it in one of my future articles) thus I’ll just cover creation of Magento database on the destination server. I will assume you do not have access to phpMyAdmin on your destination server, so I’ll show you how to do this right from MySQL client console.

First step, decide on MySQL database name, user name and password. After you do this, please document these key pieces of information. Next thing to do is open MySQL client from your destination server as administrative user and create new MySQL user and associated database. Assuming you know how to start MySQL client, here’s code for creation of database user and associated database. Please replace following data with your own:

  • db_user – Magento database user
  • db_pass – Magento database password
  • db_name – Magento database name
  • db_host – Magento database host. Most probably localhost but adjust to DB server host name or IP if you’re dealing with dedicated DB server)
CREATE USER 'db_user'@'db_host' IDENTIFIED BY 'db_pass';
GRANT USAGE ON * . * TO 'db_user'@'db_host' IDENTIFIED BY 'db_pass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
CREATE DATABASE IF NOT EXISTS db_name;
GRANT ALL PRIVILEGES ON db_name. * TO 'db_user'@'db_host';

If you have phpMyAdmin available, you can also do this procedure using its interface.

Creating automation scripts

General idea is to create and thoroughly test two shell scripts written in bash with goal of automating key parts of the transfer and eliminating human error from the equation. Important thing to point out is that these scripts should not be taken as they are, rather you should use them as starting points for developing scripts tailored to your specific environment.

First script has purpose of doing initial sync of Magento code between two servers and is to be executed while the site is still up. Updated versions of these scripts will be available inside my GitHub Gists collection, for now lets name this first one magento-transfer-1.sh.

This script requires following data:

  • SSH data for source server. We do not need password because we have configured Public-Key authentication.
  • Absolute path to web server document root on source web server.
  • Absolute path to web server document root on destination web server.

As you can see, the first script uses rsync to do the initial sync. We have selected rsync over scp due to possibility of incremental sync used later on.

Second script is much more complex as it’s intended to be executed after Magento store has been placed in maintenance mode. We will name this script magento-transfer-2.sh. This script does a few things:

  • Does incremental rsync of Magento code from source server to account for file changes that occurred after you have executed magento-transfer-1.sh script (media files changes).
  • Creates list of unnecessary tables to ignore and feeds this to mysqldump to speed up the dump process. Please keep in mind that this list isn’t as restrictive as when doing developer database dumps, because we’re talking about production database and we would like to preserve information like customer quotes.
  • Database is mysqldumped in two steps, first structure and then data. Reason for this is to avoid situation where ignore table directives affect structure as well as data, what causes missing tables on the destination server. After mysqldump, structure and data is united, compressed with gzip and sent trough SSH tunnel. On receiving side data is gunzipped and trigger definers are fixed by replacing trigger definer with name and host values of the new Magento database user. This is the fastest way to transfer large database because we’re avoiding unnecessary disk writes involved when you first do mysqldump then import, as well as manual labor.

Now here’s the magento-transfer-2.sh script code:

This script requires following data:

– SSH data for source server. We do not need password because we have configured Public-Key authentication.
– Absolute path to web server document root on source web server.
– Absolute path to web server document root on destination web server.
– MySQL database data for source server. If you were using separate DB server in the past, you should adjust the SRC_MYSQLDUMP_HOST variable.
– MySQL database data for destination server. If are going to use separate DB server in the future, you should adjust the DST_MYSQLDUMP_HOST variable.

Transfer

This chapter is what the previous chapter was all about. It’s time to place our store in maintenance mode, update Magento configuration and update DNS records with our destination server IP address.

Using automation scripts

First thing we need to do is get our automation scripts to destination server. For this task you can use scp. As far as location on the destination server is concerned, I recommend creating directory named bin inside home directory for your user account. Reason for this is that on nearly all Linux distributions /home/$USER/bin directory is automatically added to system PATH if it exists. This makes it ideal place for dumping shell scripts. Also you must make the scripts executable using following commands:

chmod +x magento-transfer-1.sh
chmod +x magento-transfer-2.sh

Next thing you must do is fill both scripts variables with relevant data like document root paths, SSH and MySQL user names, SSH and MySQL hosts as well as MySQL database names. After you are absolutely sure every piece of data is in it’s place, you can proceed with triggering first script with something like:

~/bin/magento-transfer-1.sh

This will do the initial sync of code and media files.

Following step requires for you to place Magento site in maintenance mode. All you have to do achieve this is create file named ‘maintenance.flag’ in your Magento installation root directory, in our case we’re talking about our source server.

ssh [email protected]
cd /your/magento/installation/root/
touch maintenance.flag

Please keep in mind that store transfer downtime begins with creation of this file, and time that Magento store will spend down is roughly equal to time it takes to execute our second bash script.

Next step is triggering our second script to do incremental sync of code and media files, and transfer of database between source and destination MySQL server. Here’s how:

~/bin/magento-transfer-2.sh

After this process is complete, you should proceed to configuring your destination server environment.

Adjusting Magento environment

After you have transfered your Magento code, files and database to destination server you must do two things. First thing is edit your app/etc/local.xml with new MySQL database name, user, password and new DBMS host (if you are using dedicated DB server).

Second thing is to configure crontab on your new server’s user account to trigger Magento cron. To avoid file permission issues, I advise running Magento cron from crontab belonging to user that your Apache or php-fpm instances are being started under, but this is outside of scope for this article. Changing crontab is done using “crontab -e” command and what you need to do is transfer all crontab entries from your source server (account for possible changes in document root on new environment) viewed using “crontab -l” command. Crontab editor is Vi (Vim) so if you aren’t that good with its insert, save and quit controls, additional instructions are only one Google search away.

Additionally now is the time to configure things like Solr search (requires Java), APC, Redis, Memcached but this is outside of scope for this article.

Final testing

At this point your destination server should hold both files and database, and have it’s configuration adjusted to host your Magento installation. This means you should do some testing to check is everything in order before you instruct your domain registrar to point your domain to new server IP. For you to be able to do any testing, you need assistance of your development system hosts file (/etc/hosts on unix-like operating systems, %systemroot%system32driversetc on Microsoft operating systems) to point your domain to new IP address for testing purpose. Example of hosts file entry to instruct your development system to look up example.com domain at X.X.X.X IP address would be:

X.X.X.X example.com

Now you should navigate to your store from your development machine and browse around, try logging into admin and these kind of things. If the site doesn’t load, go and inspect Magento exception log, system log, system reports and finally your web server software log file. Once everything is in order, you can proceed to changing DNS records.

Changing DNS records

Most domain registrars allow access to interface for editing domain records. If this isn’t the case, you should contact the registrar support to do this for you. Minimal action required for pointing your domain to new IP address is the adjustment of A type record. To prevent issues with sending email, you should additionally adjust TXT type record used to host SPF record, or the newer SPF type record. You should also adjust rDNS for your IP address to match your web server hostname because this is what most mail transfer agents check before relaying email messages. Failure to do so could result with emails ending up in spam folder of customers email account, or worse if messages do not get relayed at all. Reverse DNS record is usually adjusted by the person who controls the in-addr.arpa DNS zone for your IP address. This is usually hosting company, and they most likely provide access to this setting from web interface for your hosting account. Hostname is changed using “hostname” command, for more info you should check manual entry for hostname using “man hostname” command. To make your hostname changes persistent after reboot you must also modify /etc/hostname file accordingly.

After you tweak your DNS records, keep in mind that each record has TTL (time to live) value, and this value determines how long will DNS servers persist it’s values. TTL for A record represents downtime factor you do not have control of, at least not at the time Magento code, files and database transfer is complete.

In this paragraph I will present command used to inspect DNS records for domain. I’m talking about the “dig” command. Here’s example output for querying A and TXT type DNS records for example.com domain:

[email protected]:~$ dig example.com A TXT
;; Warning, extra type option
; <<>> DiG 9.9.2-P1 <<>> example.com A TXT
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50461
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 5
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com.			IN	TXT
;; ANSWER SECTION:
example.com.		51	IN	TXT	"$Id: example.com 1921 2013-10-21 04:00:39Z dknight $"
example.com.		51	IN	TXT	"v=spf1 -all"
;; AUTHORITY SECTION:
example.com.		167427	IN	NS	a.iana-servers.net.
example.com.		167427	IN	NS	b.iana-servers.net.
;; ADDITIONAL SECTION:
a.iana-servers.net.	519	IN	A	199.43.132.53
a.iana-servers.net.	519	IN	AAAA	2001:500:8c::53
b.iana-servers.net.	519	IN	A	199.43.133.53
b.iana-servers.net.	519	IN	AAAA	2001:500:8d::53
;; Query time: 21 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Dec 28 23:00:41 2013
;; MSG SIZE  rcvd: 265

Using procedure outlined in this article, I’ve managed to transfer Magento Enterprise Edition project from old server to new infrastructure consisting of two servers with under 15 minutes of transfer downtime. Of course that time spent for creating this procedure isn’t and shouldn’t be included in downtime

I hope you find this article useful and I wish you good luck with moving your Magento installation to another server.

Source: Inchoo.net

    

Consistent UI with YiiBooster

Imagine for a moment what it takes to write UI using the Twitter Bootstrap UI toolkit in the views of Yii-based web application. You have to remember what CSS classes do the thing you need and where to put them. For example, it’s certainly not obvious that you have to write class=”label label-info” instead of, […] …read more

By Mark Safronov Imagine for a moment what it takes to write UI using the Twitter Bootstrap UI toolkit in the views of Yii-based web application. You have to remember what CSS classes do the thing you need and where to put them. For example, it’s certainly not obvious that you have to write class=”label label-info” instead of, […] …read more

Source: CleverTech DevBlog

    

AngularJS Factory, Service and Provider

Services are fundamental part of Angular which execute tasks required in our application. For solving problems we face we will either use already available services like $location, $http etc.. or we’ll create our own. For most of the time using factory function to define service in our module will suffice but we should also be […] …read more

By Vladmir Rill Services are fundamental part of Angular which execute tasks required in our application. For solving problems we face we will either use already available services like $location, $http etc.. or we’ll create our own. For most of the time using factory function to define service in our module will suffice but we should also be […] …read more

Source: CleverTech DevBlog

    

Use GNU Screen + Putty to Run your Grunt Servers

Cleverstack Node Seed and Cleverstack Angular Seed running Grunt Servers to manage workflow & task automation. Aim To get two Grunt servers running in one putty SSH terminal window. One for the back-end Node Seed and one for the front-end Angular Seed. What is a “GNU Screen”? Install Screen Screen Command List Use Screen to […] …read more

By Sam Deering Cleverstack Node Seed and Cleverstack Angular Seed running Grunt Servers to manage workflow & task automation. Aim To get two Grunt servers running in one putty SSH terminal window. One for the back-end Node Seed and one for the front-end Angular Seed. What is a “GNU Screen”? Install Screen Screen Command List Use Screen to […] …read more

Source: CleverTech DevBlog

    

Use Rupa Z for quick change of directory in terminals

Z (aka Jump Around) keeps track of files and directories you access in your shell and gives you quick access to them. Save time when navigating/tabbing through long directory structures. This is a quick post to show you how to install and use it. Example Install cd /usr/bin/ git clone https://github.com/rupa/z.git vim ~/.bashrc # add […] …read more

By Sam Deering Z (aka Jump Around) keeps track of files and directories you access in your shell and gives you quick access to them. Save time when navigating/tabbing through long directory structures. This is a quick post to show you how to install and use it. Example Install cd /usr/bin/ git clone https://github.com/rupa/z.git vim ~/.bashrc # add […] …read more

Source: CleverTech DevBlog

    

Tmux Install & Usage with NodeJS & Grunt Server Split Screen

Tmux is very similar to GNU Screen but is widely known as a newer version with extra features. I prefer using Tmux to GNU screen, simply because I find it more stable (it freezes a lot less often) & much faster to use (session/windows are so easy to manage). You can rebind the CTRL+c to […] …read more

By Sam Deering Tmux is very similar to GNU Screen but is widely known as a newer version with extra features. I prefer using Tmux to GNU screen, simply because I find it more stable (it freezes a lot less often) & much faster to use (session/windows are so easy to manage). You can rebind the CTRL+c to […] …read more

Source: CleverTech DevBlog

    

Magento tip: Get a small sized version of a large production database

structure

[Guest post] Sooner or later, while working, every developer needs to deal with uniform tasks that arise every now and then. The majority of our clients usually only need minor changes in their store’s appearance or bug fixing. Working for such clients typically requires a smaller amount of work. With this type of client, the process of ‘overtaking’ the project needs to be as quick as possible.

NOTE: This is a guest post by our associate and a great Magento developer Tsvetan Stoychev – you can learn more about him and his business over here, and now – enjoy the article!

In our team, I am the one in charge of transferring an existing Magento store to our local development environment and of distributing the project among my colleagues.

Basically, what I need to do is:

  • Transfer the store’s source code from the production server to our local environment
  • Download any media files and share them with the team members
  • Dump the database and share the database file with the team members
  • Create a code repository and an issue tracking system.

Today I will elucidate the types of problems I encounter in the process of dumping and database distribution, and what I can do …read more

By Tsvetan Stoychev

structure

[Guest post] Sooner or later, while working, every developer needs to deal with uniform tasks that arise every now and then. The majority of our clients usually only need minor changes in their store’s appearance or bug fixing. Working for such clients typically requires a smaller amount of work. With this type of client, the process of ‘overtaking’ the project needs to be as quick as possible.

NOTE: This is a guest post by our associate and a great Magento developer Tsvetan Stoychev – you can learn more about him and his business over here, and now – enjoy the article!

In our team, I am the one in charge of transferring an existing Magento store to our local development environment and of distributing the project among my colleagues.

Basically, what I need to do is:

  • Transfer the store’s source code from the production server to our local environment
  • Download any media files and share them with the team members
  • Dump the database and share the database file with the team members
  • Create a code repository and an issue tracking system.

Today I will elucidate the types of problems I encounter in the process of dumping and database distribution, and what I can do …read more

Source: Inchoo.net

    

Adding links to the Top menu in Magento

Categories in the Top menu

One of the things that may sound easy to set are the top menu items, or the main menu items if you prefer. But we’re talking about Magento here and it isn’t as easy as it sounds. A specific way of creating menu items out of categories makes this fairly easy task a nightmare. Fortunately for us, Magento has a secret up its sleeve.

Magento’s logic allows only categories to appear in the top navigation. When creating a new category a simple Include in Navigation Menu setting will add the category in the navigation. Magento already explained how to add a custom link by creating a fake category and redirecting it to a specific page, but they also gave us an event to hook on to do more versatile things with the top menu.

Config

First things first. A hook has to be defined by adding the code below to the config.xml. By this we’re simply adding an event that will be fired by a dispatch event where a hook, model and method names are required.

<config>
<frontend>
<events>
...read more

By Damir Korpar

Categories in the Top menu

One of the things that may sound easy to set are the top menu items, or the main menu items if you prefer. But we’re talking about Magento here and it isn’t as easy as it sounds. A specific way of creating menu items out of categories makes this fairly easy task a nightmare. Fortunately for us, Magento has a secret up its sleeve.

Magento’s logic allows only categories to appear in the top navigation. When creating a new category a simple Include in Navigation Menu setting will add the category in the navigation. Magento already explained how to add a custom link by creating a fake category and redirecting it to a specific page, but they also gave us an event to hook on to do more versatile things with the top menu.

Config

First things first. A hook has to be defined by adding the code below to the config.xml. By this we’re simply adding an event that will be fired by a dispatch event where a hook, model and method names are required.

<config>
<frontend>
<events>
...read more

Source: Inchoo.net

    

Yii CGridView add custom button

Hi buddies !,
This tutorial shows about how to add a custom button with your own icon for your CGridView of Yii framework

Step 1
Add a new array element under ‘class’ => ‘CButtonColumn’
as follow The default buttons are

'template' => '{view}{update}{delete}',

Now I am adding a new button for reply

'template' => '{reply}{view}{update}{delete}',

Step 2 Then add a new element in the name reply under button array as follows

'buttons' => array(
'reply' => array( //the name {reply} must be same
'label' => 'Reply', // text label of the button
'url' => 'CHtml::normalizeUrl(array("dashboard/mail/id/".rawurlencode($data->feedback_email)."/f_id/".$data->feedback_id))', //Your URL According to your wish
'imageUrl' => Yii::app()->baseUrl . '/images/reply_mail_icon.png', // image URL of the button. If not set or false, a text link is used, The image must be 16X16 pixels
...read more

Hi buddies !,
This tutorial shows about how to add a custom button with your own icon for your CGridView of Yii framework

Step 1
Add a new array element under ‘class’ => ‘CButtonColumn’
as follow The default buttons are

'template' => '{view}{update}{delete}',

Now I am adding a new button for reply

'template' => '{reply}{view}{update}{delete}',

Step 2 Then add a new element in the name reply under button array as follows

'buttons' => array(
'reply' => array( //the name {reply} must be same
'label' => 'Reply', // text label of the button
'url' => 'CHtml::normalizeUrl(array("dashboard/mail/id/".rawurlencode($data->feedback_email)."/f_id/".$data->feedback_id))', //Your URL According to your wish
'imageUrl' => Yii::app()->baseUrl . '/images/reply_mail_icon.png', // image URL of the button. If not set or false, a text link is used, The image must be 16X16 pixels
...read more

Source: Yii Framework

    

WordPress Role Based Authentication in Yii framework

This tutorial is for people that are integrating Yii into WordPress. Meaning that WordPress is the host platform, and that Yii will be handling AR, CRUD, etc.

Our User Class

This should be saved in an auto-loaded location, in our application it was application.components, which was included as part of our application.import[].

<?php
class wpUser extends CApplicationComponent implements IWebUser, IApplicationComponent {
public function init ()
{
parent::init();
}
function checkAccess ($operation, $params = array()) {
return current_user_can($operation);
}
function getId() {
return get_current_user_id();
}
function getIsGuest () {
$is_user_logged_in = is_user_logged_in();
return ! ...read more

This tutorial is for people that are integrating Yii into WordPress. Meaning that WordPress is the host platform, and that Yii will be handling AR, CRUD, etc.

Our User Class

This should be saved in an auto-loaded location, in our application it was application.components, which was included as part of our application.import[].

<?php
class wpUser extends CApplicationComponent implements IWebUser, IApplicationComponent {
public function init ()
{
parent::init();
}
function checkAccess ($operation, $params = array()) {
return current_user_can($operation);
}
function getId() {
return get_current_user_id();
}
function getIsGuest () {
$is_user_logged_in = is_user_logged_in();
return ! ...read more

Source: Yii Framework

    

Magento Configurable Cron

By Damir Korpar

Cron in Magento is fairly easy to configure. A few lines in config.xml, a method and it’s done. But what happens if you want to spice it up a bit and create a schedule-configurable cron? Fortunately for us, Magento has that already included in the system and it’s pretty easy to implement.

Cron itself is more or less straightforward. As seen in the code below, it is defined in a config.xml file with two main parts: schedule and a method to be ran. A sample below shows a cron job named “my_cron” that runs “doSomething” method inside the observer file every five minutes. If you’re not familiar with the cron schedule format, there’s a bunch of the articles and cron generators on the internet.

<config>
<crontab>
<jobs>
<my_cron>
<schedule>
<cron_expr>*/5 * * * *</cron_expr>
...read more

Source: Inchoo.net

Install and Start Apache Solr in 5 minutes

By Kristijan Glibo

wget

Search has become a default way for users to find products on websites. Despite main navigation and other site navigation tools, more and more customers are using on – site search to find what they want. Speaking about default Magento search I don’t have much to say, I can only give you advice to use some custom solution to get the most of it for your UX.

If you want to go one step further and make the best solution for your Magento search, use Apache Solr. Ok? Ok! So, what is Solr?

“SolrTM is the popular, blazing fast open source enterprise search platform from the Apache LuceneTM project. Its major features include powerful full-text search, hit highlighting, faceted search, near real-time indexing, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world’s largest internet sites.”

http://lucene.apache.org

There’s a lot of terminology in this official Apache Solr definition, but don’t let that scare you. Installing example Solr and start …read more

Source: Inchoo.net

Magento functional testing with casper.js

By Stanislav Mihic

Run test

Testing can be boring and time consuming task. So why don’t we use some tools and make our lives easier? In Magento there are numerous “boring” tasks that need to be done after the first install and then again when you test a new functionality. For example, create a test account, add product to cart, go trough checkout process, add product to wishlist, compare etc.Casper.js seems like the right tool for these “repeated” tasks. So, what is casper.js!?

CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks

We will skip the installation process as it is very straightforward. So let’s jump into testing right away.

We will create two scenarios for demo purpose

Scenario 1

Open home page of your Magento store, click on log in link, open “Login or Create An Account” Magento page, find the “Create an Account” button and click on it to open “Create an Account” page, fill out the form, submit it, wait to be redirected to My Account dashboard and then …read more

Source: Inchoo.net