Check if website is available or down

Performs a cURL-Request to check, if a website exists / is online

//Cron job comand line: /usr/local/bin/php /home/USERNAME/site-monitor/monitor.php > /dev/null

//returns true, if domain is availible, false if not
function isDomainAvailible($domain) {
	//check, if a valid url is provided
	if(!filter_var($domain, FILTER_VALIDATE_URL)) {
		return false;
	//initialize curl
	$curlInit = curl_init($domain);
	//get answer
	$response = curl_exec($curlInit);
	if ($response) return true;
	return false;

if (!isDomainAvailible('')) {
	echo "Woops, nothing found there.";
	$message = 'Woops, Your site was down on '.date("Y-m-d H:i:s");
	$headers = 'From: [email protected]';
	mail("[email protected]", "Website is down", $message, $headers);
	error_log($message, 0);


Magento: Retrieve attributes by groupId

Problem: how to retrieve product attributes by group id.
See here:

Possible solution:

require_once 'path/to/app_dir/app/Mage.php';
$product = Mage::getModel('catalog/product');
$product->setAttributeSetId('THE ATTRIBUTE SET YOU WANT TO USE');
$collection = $product->getAttributes($groupId, false);
foreach($collection as $attribute){
//do something with the attribute


Magento: Running script out side Magento Folder and Updating Project Database

Magento: Running script out side Magento Folder and Updating Project Database

Magento: Running script out side Magento Folder and Updating Project Database

Place this script ‘image.php’ out side magento folder and run this with http://yoursite/image.php, this will update all product images if there is no small or thumbnail image.
It will make first image as thumb and small image.

An example to run script out side magento folder.

require ‘app/Mage.php’;

$products = Mage::getModel(‘catalog/product’)->getCollection()->addAttributeToSelect(‘*’);
foreach ($products as $product) {
 if (!$product->hasImage()) continue;
 if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
 if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());

Magento: Showing Breadcrumbs Anywhere in Magento

In Magento, by default there is a reference place where breadcrumbs get showed, that is just above the content reference! But, sometimes you need to show the breadcrumbs twice! above and below the content. Or sometimes you just need to show the breadcrumbs inside the content, due to some designing issue! I’ve gone through these situation a lot, and thought why not post a solution in my blog?
Here’s the “magic code” for breadcrumbs to show anywhere in Magento

<?php  echo $this->getLayout()->getBlock("breadcrumbs")->toHtml()?>

Its very simple, it just gets the block breadcrumbs defined in page.xml and echoes it as html.
Happy coding!

Joomla-JoomFish: How to fix Joom!Fish saving language configuration error, unknown column ‘l.ordering’ in ‘order clause’

When I go for language activation to the JoomFish language manager, I get this error when trying to activate default language:

An error occured while saving your languages

Also in the language configuration see the following error:

Unknown column 'l.ordering' in 'order clause' SQL=SELECT l.* FROM jos_languages AS l ORDER BY l.ordering
Warning: Invalid argument supplied for foreach() in www/administrator/components/com_joomfish/models/languages.php on line 188


SSH: How to Fix Permissions on Files and Directories?

Here are the SSH commands to fix your permissions on a mass level:

    find ~/public_html -type d -exec chmod 755 {} \;

    find ~/public_html -type f -exec chmod 644 {} \;

Basically, the format is to find, or look, in the path of ~(which means home) and then in public_html. (If you want to look in a different directory, you can change this. e.g. ~/public_html/myblog) And then it looks for the document type, be it directory (d) or file (f), and executes the chmod(change mode) command to change the permissions on all results.

Magento: Replace Price Difference with Actual Price in Magento Configurable Product Options

This is performed by javascript. You need to modify the method getOptionLabel in js/varien/configurable.js (this is Magento, your milage may vary depending on the version you’re using).

This method receives the option and the price difference to be applied. If you want to just show the absolute price of the different options, you need to calculate them yourself, using the absolute base value of the configurable product and the absolute difference of the option.

Magento: Rating showing twice on product pages

We came across an issue recently, where the customer’s product pages review section was showing the rating stars twice. We tried to locate the issue, but nothing seemed to work. Finally found out the fix .

Just goto the phpmyadmin and run this SQL query,

TRUNCATE  `rating_option_vote` ;
TRUNCATE  `rating_option_vote_aggregated` ;

jQuery: Append a CSS class to any item or last item

<script type="text/javascript">
	jQuery("p:last").addClass(" last");

It’s important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.

More than one class may be added at a time, separated by a space, to the set of matched elements, like so:

$("p").addClass("myClass yourClass");


Pin It on Pinterest