View customer_group_massupdate_magento.php
<?php | |
$customerGroupId = SOME_CUSTOMER_GROUP_ID; | |
$table = Mage::getModel('customer/customer')->getResource() | |
->getWriteConnection() | |
->getTable('customer/entity'); | |
$query = "UPDATE {$table} SET group_id = {$customerGroupId} WHERE group_id != {$customerGroupId}"; | |
$conn->query($query); | |
?> |
View create_group_prices_magento.php
<?php | |
class Namespace_Module_Model_Price_Import extends Mage_Core_Model_Abstract | |
{ | |
/** | |
* DB Connection | |
* | |
* @var Varien_Db_Adapter_Interface | |
*/ | |
protected $_conn; |
View next_business_day.php
<?php | |
/** | |
* Retrieve the next business day with an optional leadtime. | |
* If leadtime = 1 => find the next business day | |
* If leadtime = 2 => find the "next next" business day | |
* etc... | |
* | |
* @param int $leadtime | |
* @return string|bool | |
*/ |
View run_method.php
#!/usr/bin/php -f | |
<?php | |
require_once 'abstract.php'; | |
class Herve_Run_Method extends Mage_Shell_Abstract | |
{ | |
protected function _parseArgs() | |
{ |
View convert_string_to_url_key.php
<?php | |
$string = 'My String'; | |
$urlKeyString = Mage::getSingleton('catalog/product')->formatUrlKey($string); | |
// Returns => my-string | |
?> |
View cart_price_rule_1_steps.txt
This is a quick an easy hack to programmatically create a cart price rule. | |
1. Temporarely edit Mage_Adminhtml_Promo_QuoteController::saveAction() | |
2. Around line 123, you will find $data = $this->getRequest()->getPost(); | |
3. Below this line create a new line containing : | |
var_export($data); | |
die(); |
View create_cms_block.php
<?php | |
$content = <<<EOD | |
Block Content line 1 | |
Block Content line 2 | |
EOD; | |
$cmsBlock = Mage::getModel('cms/block')->addData( | |
array( | |
'title' => 'Block Title', | |
'identifier' => 'block_identifier', |
View Observer.php
<?php | |
class My_Module_Model_Observer { | |
/** | |
* Update admin menu with dynamic items | |
*/ | |
public function updateAdminMenu() | |
{ | |
$menu = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu/MAIN_MENU_ITEM/children/MENU_ITEMS_CONTAINER/children'); |
View htaccess_avoid_robots_indexing.sh
# Make sure mod_headers is enabled in Apache | |
sudo a2enmod headers | |
# Place this in .htaccess | |
<IfModule mod_headers.c> | |
Header set X-Robots-Tag "noindex, nofollow" | |
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" | |
Header set Pragma "no-cache" | |
</IfModule> |
View cache_warmer.sh
#!/bin/bash | |
URL='www.domain.nd' | |
SITEMAP='sitemap.xml' | |
wget --quiet http://$URL/$SITEMAP --no-cache --output-document - | egrep -o "http://$URL[^<]+" | while read line; do | |
time curl -A 'Cache Warmer' -s -L $line > /dev/null 2>&1 | |
echo $line | |
done |