Posts

Showing posts from February, 2018

Magento Development and Coding

Image
Magento 'Shop by Brand' in SideBar: First, create a template file, label it productbrand.phtml then keep it in catalog/product folder after which you can copy the code in it given below, also paste it in your productbrand.phtml. Make use of the product brand and include it in the database, which needs a label of all the brands you are interested to include and use it to make a comprehensive working out with brands mentioned of all items. <div> <div> <h4> <span>Product Brands</span></h4> </div> <div style="padding-left:8px;"> <?php $product = Mage::getModel('catalog/product'); $attributes = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($product->getResource()->getTypeId())->addFieldToFilter('attribute_code', 'manufacturer'); $attribute = $attributes->getFirstItem()->setEntity($product->getResource());

PHP Coding Snippets for Variable Purposes

Image
Calculate Distance between Two Maps Coordinates: To discover the distance between two coordinates located on the earth, found out if you provide details of your coordinates to see the distance between them. Two longitude and latitude coordinates are required which you need to label and input as values defining the location which you want to measure to the ends to get a magnitude of the distance in between. function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {     $theta = $longitude1 - $longitude2;     $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));     $miles = acos($miles);     $miles = rad2deg($miles);     $miles = $miles * 60 * 1.1515;     $feet = $miles * 5280;     $yards = $feet / 3;     $kilometers = $miles * 1.609344;     $meters = $kilometers * 1000;     return compact('miles','feet','yards',

Snippet in PHP for Unzipping a File

Image
Using this below PHP snippet, you can be able to unzip a file on it whenever you rip with this code running through PHP. The initial unzip function checks the file to unzip and sees a location with an unlink action confirming the unzipping environment you execute. Making use of this coding process has better results you comply with as unzipping software’s are not reliable and might cause bad sectors on your hard disk. function unzip($location,$newLocation) {         if(exec("unzip $location",$arr)){             mkdir($newLocation);             for($i = 1;$i< count($arr);$i++){                 $file = trim(preg_replace("~inflating: ~","",$arr[$i]));                 copy($location.'/'.$file,$newLocation.'/'.$file);                 unlink($location.'/'.$file);             }             return TRUE;         }else{             return FALSE;         } } function unzip($location,$newLocation) {