This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Namespace_Module_Model_Price_Import extends Mage_Core_Model_Abstract | |
{ | |
/** | |
* DB Connection | |
* | |
* @var Varien_Db_Adapter_Interface | |
*/ | |
protected $_conn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php -f | |
<?php | |
require_once 'abstract.php'; | |
class Herve_Run_Method extends Mage_Shell_Abstract | |
{ | |
protected function _parseArgs() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = 'My String'; | |
$urlKeyString = Mage::getSingleton('catalog/product')->formatUrlKey($string); | |
// Returns => my-string | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |