Skip to content

Instantly share code, notes, and snippets.

View ravixp's full-sized avatar

Cycle XP ravixp

  • Edinburgh
  • 06:53 (UTC +01:00)
View GitHub Profile
@ravixp
ravixp / wordpress-staging-url.md
Last active October 30, 2017 18:03
WordPress: Changing the Site URL and Home Settings, migrating from the live website to the staging website

Add the site URL and home settings in wp-config.php without editing database.

define('WP_HOME','https://staging.example.co.uk');
define('WP_SITEURL','https://staging.example.co.uk');
@ravixp
ravixp / Magento1-Local-Live.md
Last active October 17, 2017 09:50
Magento 1 - Local/Staging to Live or Live to Local/Staging

Exporting SQL (Backup SQL) on old server

$ mysqldump -u database_name -p database_user > anyname_backup.sql

Importing SQL on new server

$ mysql -u database_user -p database_name < anyname_backup.sql

To Git Pull on a new server

@ravixp
ravixp / ssh-cheatsheets.md
Last active October 29, 2017 16:17
SSH CheatSheets

SSH Cheatsheets

Where I am? it shows the full path

$ pwd

Move into another directory

$ cd /var/www/vhosts/example.com/conf/
@ravixp
ravixp / SampleCode.php
Last active October 17, 2017 09:52
Sample Coding in Magento 1.9. I type a good naming conversion for classes and IDs. I add the comments to the end of every closed tags. Simple and neat formatting for PHP if else conditions / for each loop, etc. I type coding the way for easy reading for designers/developers
<?php
/*
@Orginal Author: Ravi Panghat
@Orginal Update Date: 12/01/2014
@Orginal Description: Setup the Product Page, layout, Product Image, Tabs
@Last Author: Ravi Panghat
@Last Update Date: 20/03/2016
@Last Update Description: The client Richard requests to add the product's brand logo image. Implemented the brand logos.
*/ ?>
@ravixp
ravixp / add-external-js-link-local.md
Last active July 14, 2017 09:15
Magento 1: Add the add the external JS link or CDN JS link to head using XML (local.xml)
@ravixp
ravixp / add-product-image-email-order.php
Last active July 13, 2017 14:32
Magento 1: Add the product image on the email order (template/email/order/items/order/default.phtml)
<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>
<?php if ($_item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$parentId = Mage::getModel('catalog/product_type_configurable')
->getParentIdsByChild($_item->getProductId());
$_product = Mage::getModel('catalog/product')
->setStoreId($_item->getOrder()->getStoreId())
->load($parentId);
} else {
@ravixp
ravixp / remove-all-scripts.php
Created July 12, 2017 16:43
PHP: Remove all scripts from head including script
<?php $head_noscript = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $head_text); ?>
<?php echo $head_noscript; ?>
@ravixp
ravixp / check-if-h1-existing.php
Last active July 12, 2017 17:22
Magento 1: Check if H1 tag is existing on the product description. The client wants to add the H1 tag on the description in the certain products (magento backend). Change H1 to H2 in the page title if H1 found on the description.
<?php $product_description = $_helper->productAttribute($_product, $_product->getDescription(), 'description'); ?>
<?php if( strstr($product_description, '<h1') ) : // Check if H1 tag exists on the description ?>
<div class="page-title">
<h2 class="h1-page-title h1-title-exists-on-description">
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</h2>
</div><!--/.page-title -->
<?php else: // Check if H1 tag exists on the description ?>
<div class="page-title">
@ravixp
ravixp / remove-ul-tag-header-links.php
Last active July 12, 2017 17:22
Magento 1: Remove the <ul> tag from the static block for the custom header links
@ravixp
ravixp / include-phtml-file-cms-page.xml
Last active July 12, 2017 17:28
Magento 1 XML: Include the phtml file inside a CMS page under the design.
<reference name="content">
<block type="core/template" template="foldername/templatename.phtml" />
</reference>