Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active July 26, 2024 07:54
Show Gist options
  • Save iegik/4452191 to your computer and use it in GitHub Desktop.
Save iegik/4452191 to your computer and use it in GitHub Desktop.
Make Magento Template Path Hints hidden, to not distroy page layout
#!/bin/bash
find . -type d -exec chmod 777 {} \;
find . -type f -exec chmod 644 {} \;
sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx *
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx *
#!/bin/bash
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod o+w var var/.htaccess var/cache var/sessions var/report includes includes/config.php app/etc
# chmod 550 pear
chmod -R o+w media
# In order run Magento Connect you may need to TEMPORARILY loosen file permissions by executing these commands in the root of the Magento installation:
# find . -type d -exec chmod 777 {} \;
# find . -type f -exec chmod 644 {} \;
# set umask/ACL ~/public_html/
#mount -o remount,acl /
#setfacl -d -m u::rwx,g::rwx,o::rx ../
#chmod g+s ../
#umask 2 -R
## Symfony2
## Clear Cache
# rm -rf app/cache/*
# rm -rf app/logs/*
## Set Permissions
# sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
# sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
#!/bin/bash
# Reindex sample products
php shell/indexer.php --reindex catalog_product_attribute
php shell/indexer.php --reindex catalog_product_price
php shell/indexer.php --reindex catalog_url
php shell/indexer.php --reindex catalog_product_flat
php shell/indexer.php --reindex catalog_category_flat
php shell/indexer.php --reindex catalog_category_product
php shell/indexer.php --reindex catalogsearch_fulltext
php shell/indexer.php --reindex cataloginventory_stock
# Clear cache, session and logs
rm -rf var/*
#!/bin/bash
SITENAME="mt";
ENVIROMENT="dev";
# SET THIS VARIABLES FIRST
DIRECTORY=$SITENAME"."$ENVIROMENT;
DATABASE=$SITENAME"_"$ENVIROMENT;
HOSTNAME=$SITENAME"."$ENVIROMENT"."`whoami`;
# Remove old configuration
rm -rf app/etc/local.xml
# Create database for site (if not exist)
mysql -uroot -e "create database if not exists "$DATABASE
# (Re)install Magento
php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "localhost" \
--db_name $DATABASE \
--db_user "root" \
--use_rewrites "yes" \
--use_secure "no" \
--use_secure_admin "no" \
--skip_url_validation "yes" \
--admin_firstname "Store" \
--admin_lastname "Owner" \
--admin_email "info@example.com" \
--admin_username "admin" \
--admin_password "secret123" \
--url "http://"$HOSTNAME"/" \
--secure_base_url "https://"$HOSTNAME"/"
# --db_pass "" \
# After inserting magento sample data - password must be reset
mysql -uroot $DATABASE -e "UPDATE admin_user SET password=CONCAT(MD5('DDZadmin'), ':DDZ') WHERE username='admin';"
SITENAME="mt";
ENVIROMENT="dev";
# SET THIS VARIABLES FIRST
DATABASE=$SITENAME"_"$ENVIROMENT;
# Insert Test Products
mysql -uroot $DATABASE < ~/www/magento_sample_data_for_1.6.1.0.sql
# After inserting magento sample data - password must be reset
mysql -uroot $DATABASE -e "UPDATE admin_user SET password=CONCAT(MD5('DDZadmin'), ':DDZ') WHERE username='admin';"
rm -rf var/cache/*
#!/bin/bash
SITENAME="mt";
ENVIROMENT="dev";
# SET THIS VARIABLES FIRST
DIRECTORY=$SITENAME"."$ENVIROMENT;
DATABASE=$SITENAME"_"$ENVIROMENT;
HOSTNAME=$SITENAME"."$ENVIROMENT"."`whoami`;
# Add theme for site
mysql -uroot $DATABASE <<EOF
# Add new Store
INSERT INTO \`core_store_group\` VALUES ('',1,'magicwand',3,4); -- ...2,2) by default
# Add new Store View
INSERT INTO \`core_store\` VALUES ('','magicwand_en',1,LAST_INSERT_ID(),'English',0,1);
SET @new_core_store_group = LAST_INSERT_ID();
# Set theme for store view
INSERT INTO \`core_config_data\` VALUES
('','stores',@new_core_store_group,'design/package/name','bootstrapped'),
('','stores',@new_core_store_group,'design/theme/template','magicwand'),
('','stores',@new_core_store_group,'design/theme/skin','magicwand'),
('','stores',@new_core_store_group,'design/theme/layout','penisextender');
EOF
rm -rf var/cache/*
[style^="position:relative"] {
border: 0!important;
font-size: 0!important;
margin: 0!important;
padding: 0!important;
}
[style^="position:relative"] > * {
font-size: 10pt!important;
}
[style^="position:relative"] [title^="frontend"], [style^="position:relative"] [title^="adminhtml"] {
display: none;
}
[style^="position:relative"]:hover {
outline: red dotted .1em!important;
}
[style^="position:relative"]:hover > [title^="frontend"], [style^="position:relative"]:hover > [title^="adminhtml"] {
display: block!important;
}
[title^="frontend"], [title^="adminhtml"] {
background-color: rgba(128, 0, 0, 1)!important;
}
[title^="frontend"]:hover, [title^="adminhtml"]:hover {
background-color: rgba(128, 0, 0, 1)!important;
}
#!/bin/bash
# usage: magento [-?][-d "ET"][-bmc -p "Test"][-o "Mage_Model_Class"]
usage()
{
cat << EOF
usage: $0 [-?][-d "ET"][-bmc -p "Test"][-o "Mage_Model_Class"]
With this script you can create your own MODULE, copy Mage class and...
OPTIONS:
-? --help Show this message
-d --dev --developer Developer(s) or company name
-p --prj --project Create new default project
-b --block Create project default Block
-m --model Create project default Model
-c --controller Create project default Controller
-o --over --override Override Mage class (object)
-v --version Verbose
EOF
}
DEV="ET"
MODULE=
CLASS=
BLOCK=
MODEL=
CONTROLLER=
CONFIG=
VERBOSE=
while getopts "hn:p:bmc:o:v" OPTION
do
case $OPTION in
\?|\-help)
usage
exit 1
;;
d|\-dev)
DEV=$OPTARG
;;
p)
MODULE=$OPTARG
;;
o|\-over|\-override)
CLASS=$OPTARG
;;
b|\-block)
BLOCK=${OPTARG:-"View"}
;;
m|\-model)
MODEL=1
;;
c|\-controller)
CONTROLLER=${OPTARG:-"Index"}
;;
v|\-version)
VERBOSE=1
;;
esac
done
if [[ -z $MODULE ]] && [[ -z $CLASS ]] && [[ -z $VERBOSE ]]
then
usage
exit 1
fi
if [ "$DEV" ] && [ "$MODULE" ]
then
echo "Including Module to the project: app/etc/module/"$DEV"_"$MODULE".xml"
mkdir -p "app/etc/module/"
echo "<?xml version=\"1.0\"?>
<config>
<modules>
<"$DEV"_"$MODULE">
<active>true</active>
<codePool>local</codePool>
</"$DEV"_"$MODULE">
</modules>
</config>" > "app/etc/module/"$DEV"_"$MODULE".xml"
if [ "$BLOCK" ]
then
echo "Writing Block: app/code/local/"$DEV"/"$MODULE"/Block/$BLOCK.php"
mkdir -p "app/code/local/"$DEV"/"$MODULE"/Block/"
echo "<?php
/**
* @codepool Local
* @category "$DEV"
* @package "$DEV"_"$MODULE"
* @class "$DEV"_"$MODULE"_"$BLOCK"
*/
class "$DEV"_"$MODULE"_Block_$BLOCK extends Mage_Core_Block_Template
{
private $message;
private $att;
protected function createMessage($msg) {
$this->message = $msg;
}
public function receiveMessage() {
if($this->message != '') {
return $this->message;
} else {
$this->createMessage('Hello World');
return $this->message;
}
}
protected function _toHtml() {
$html = parent::_toHtml();
if($this->att = $this->getMyCustom() && $this->getMyCustom() != '') {
$html .= '<br />'.$this->att;
} else {
$html .= '<br />No Custom Attribute Found';
}
return $html;
}
}
" > "app/code/local/"$DEV"/"$MODULE"/Block/$BLOCK.php"
CONFIG+="\
<!-- Block -->\
"
fi
if [ "$CONTROLLER" ]
then
echo "Writing Controller: app/code/local/"$DEV"/"$MODULE"/controllers/"$CONTROLLER"Controller.php"
mkdir -p "app/code/local/"$DEV"/"$MODULE"/controllers/"
echo "<?php
/**
* @codepool Local
* @category "$DEV"
* @package "$DEV"_"$MODULE"
* @class "$DEV"_"$MODULE"_"$CONTROLLER"Controller
*/
class "$DEV"_"$MODULE"_"$CONTROLLER"Controller extends Mage_Core_Controller_Front_Action
{
public function indexAction(){
exit(\"ok\");
}
}
" > "app/code/local/"$DEV"/"$MODULE"/controllers/"$CONTROLLER"Controller.php"
MODULENAME=$(echo $MODULE | tr '[A-Z]' '[a-z]');
CONFIG+="\
<frontend>\
<routers>\
<"$MODULENAME">\
<use>standard</use>\
<args>\
<module>"$DEV"_"$MODULE"</module>\
<frontName>"$MODULENAME"</frontName>\
</args>\
</"$MODULENAME">\
</routers>\
</frontend>\
"
fi
fi
echo "Writing config for module: app/code/local/"$DEV"/"$MODULE"/etc/config.xml"
mkdir -p "app/code/local/"$DEV"/"$MODULE"/etc/"
echo "<?xml version=\"1.0\"?>
<config>
<modules>
<"$DEV"_"$MODULE">
<version>0.1.0</version>
</"$DEV"_"$MODULE">
</modules>
"$CONFIG"
<global>
<blocks>
<"$DEV"_"$MODULE">
<class>"$DEV"_"$MODULE"_Block</class>
</"$DEV"_"$MODULE">
</blocks>
</global>
</config>" > "app/code/local/"$DEV"/"$MODULE"/etc/config.xml"
exit 1
fi
if [ "$CLASS" ]
then
core_dir="./app/code/core/`echo $CLASS | sed 's/_/\//g'`";
local_dir="`echo $core_dir | sed 's/core/local/1'`";
echo "Making directory..."
echo $local_dir;
mkdir -p $local_dir;
echo "Cleaning empty directory..."
rm -r $local_dir;
echo "Copyng..."
echo $core_dir.php
echo "to.."
echo $local_dir.php
cp $core_dir.php $local_dir.php;
echo "Created: "`ls $local_dir/..`
exit 1
fi
NAME="mt";
ENV="test";
USER=`whoami`
DIRECTORY=$NAME"."$ENV
mkdir -p $DIRECTORY && cd $DIRECTORY;
git init
git remote add magento git@gitlab.ddz.fr:magento.git
git pull magento master
# TODO: git pull magento v1.7.0.2
#git fetch magento master
# Install required modules
git remote add magento_modules git@gitlab.ddz.fr:magento_modules.git
git pull magento_modules module_magestore_bannerslider
git pull magento_modules module_tm_easytabs
#git fetch magento_modules module_magestore_bannerslider
#git fetch magento_modules module_tm_easytabs
#git rebase origin/master
# Add Twitter`s Bootstrap theme for Magento
git remote add magento_themes git@gitlab.ddz.fr:magento_themes.git
git pull magento_themes theme_bootstrapped
# Latest Twitter`s Bootstrap styles, javascripts, images
# git submodule add -b 3.0.0-wip git://github.com/twitter/bootstrap.git skin/frontend/bootstrapped/default
# git submodule add git@gitlab.ddz.fr:cdn.git js/libs
#git --ignore-submodules=dirty
# git submodule update --init
# git cm "Add Bootstrap submodule"
# Override styles and layouts for Penisextender theme, which is based on Twitter/Bootstrap
git pull magento_themes theme_penisextender
#git fetch magento_themes theme_bootstrapped
#git fetch magento_themes theme_penisextender
#git rebase origin/master
# Ignore for Magento ( after all modules fetched, overwise - some base files will be ignored )
curl https://raw.github.com/github/gitignore/master/Magento.gitignore >> .gitignore
# Create database for site
mysql -uroot -e "create database "$NAME"_"$ENV
# Install Magento
rm app/etc/local.xml
php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "localhost" \
--db_name $NAME"_"$ENV \
--db_user "root" \
--use_rewrites "yes" \
--use_secure "no" \
--use_secure_admin "no" \
--skip_url_validation "yes" \
--admin_firstname "Store" \
--admin_lastname "Owner" \
--admin_email $USER"@ddz.fr" \
--admin_username "admin" \
--admin_password "secret123" \
--url "http://"$NAME"."$ENV"."$USER"/" \
--secure_base_url "https://"$NAME"."$ENV"."$USER"/"
# --db_pass "" \
# Add theme for site
mysql -uroot $NAME"_"$ENV <<EOF
# Add new Store
INSERT INTO \`core_store_group\` VALUES ('',1,'penisextender',3,4); -- ...2,2) by default
# Add new Store View
INSERT INTO \`core_store\` VALUES ('','penisextender_en',1,LAST_INSERT_ID(),'English',0,1);
SET @new_core_store_group = LAST_INSERT_ID();
# Set theme for store view
INSERT INTO \`core_config_data\` VALUES
('','stores',@new_core_store_group,'design/package/name','bootstrapped'),
('','stores',@new_core_store_group,'design/theme/template','penisextender'),
('','stores',@new_core_store_group,'design/theme/skin','penisextender'),
('','stores',@new_core_store_group,'design/theme/layout','penisextender');
EOF
# Insert Test Products
mysql -uroot $NAME"_"$ENV < ~/www/magento_sample_data_for_1.6.1.0.sql
mv app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.9-1.6.0.0.10.php app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.9-1.6.0.0.10.php_
mv app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php_
mv app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php app/code/core/Mage/Reports/sql/reports_setup/upgrade-1.6.0.0-1.6.0.0.1.php_
mv app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php_
mv app/code/core/Mage/Captcha/sql/captcha_setup/install-1.7.0.0.0.php app/code/core/Mage/Captcha/sql/captcha_setup/install-1.7.0.0.0.php_
mv app/code/core/Mage/Api2/sql/api2_setup/install-1.0.0.0.php app/code/core/Mage/Api2/sql/api2_setup/install-1.0.0.0.php_
# After inserting magento sample data - password must be reset
mysql -uroot $NAME"_"$ENV -e "UPDATE admin_user SET password=CONCAT(MD5('DDZadmin'), ':DDZ') WHERE username='admin';"
rm -rf var/*
xdg-open "http://"$NAME"."$ENV"."$USER"/index.php/gaming-computer.html"
# Undo:
#cd ..
#rm -rf $DIRECTORY
#mysql -uroot -e "drop database "$NAME"_"$ENV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment