Skip to content

Instantly share code, notes, and snippets.

@yireo
yireo / mage_passwordreset.php
Last active October 13, 2015 12:18
Script to reset customer password
<?php
require_once 'app/Mage.php';
Mage::app();
$password = 'password01';
$customerId = 1;
$customer = Mage::getModel('customer/customer')->load($customerId);
$customer->setPassword($password);
$customer->setConfirmation($password);
@yireo
yireo / local.xml
Created February 12, 2013 10:53
Magento XML-layout update to set NOINDEX,FOLLOW tag on Layered Navigation pages (kudos @hans2103)
<layout>
<catalog_category_layered>
<reference name="head">
<action method="setRobots"><meta>NOINDEX,FOLLOW</meta></action>
</reference>
</catalog_category_layered>
<catalog_category_layered_nochildren>
<reference name="head">
<action method="setRobots"><meta>NOINDEX,FOLLOW</meta></action>
@yireo
yireo / create_website_scope.php
Last active October 1, 2020 11:02
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
@yireo
yireo / yireo_bingtranslate_product.php
Last active December 17, 2015 00:49
Magento script to automate product-translations using the Yireo BingTranslate extension
<?php
// Basic settings
$storeCodes = array('french', 'german', 'danish', 'dutch');
$productAttributes = array('name', 'short_description', 'description');
// Initialize Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@yireo
yireo / yireo_bingtranslate_basic.php
Last active December 17, 2015 00:58
Magento script to translate a specific text using the Yireo BingTranslate extension
<?php
// Basic settings
$text = 'Hello World';
$source = 'en';
$destination = 'fr';
// Startup the application
require_once 'app/Mage.php';
Mage::app();
@yireo
yireo / vm2mage_reset_products.sql
Last active December 17, 2015 00:59
Vm2Mage SQL-file to wipe out all Magento products
-- Disable foreign key checks temporarily --
SET SQL_MODE='';
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
-- Reset all product information
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
@yireo
yireo / vm2mage_reset_categories.sql
Created May 6, 2013 13:18
Vm2Mage SQL-file to wipe out all Magento categories
-- Disable foreign key checks temporarily --
SET SQL_MODE='';
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
-- Reset all vm2mage information
TRUNCATE TABLE `vm2mage_categories`;
-- Reset all category information
TRUNCATE TABLE `catalog_category_entity`;
@yireo
yireo / vm2mage_reset_customers.sql
Created May 6, 2013 13:19
Vm2Mage SQL-file to wipe out all Magento customers
-- Disable foreign key checks temporarily --
SET SQL_MODE='';
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
-- Reset all vm2mage information
TRUNCATE TABLE `vm2mage_categories`;
-- Reset all customer information
TRUNCATE TABLE `customer_address_entity`;
@yireo
yireo / yr_delete_urlrewrites.php
Last active December 19, 2015 00:09
Manually delete all entries from the core_url_rewrites folder (make sure to reindex afterwards)
<?php
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$urlRewrites = Mage::getModel('core/url_rewrite')->getCollection();
foreach($urlRewrites as $urlRewrite) {
$urlRewrite->delete();
}
@yireo
yireo / yr_joomla_fix_componentid.php
Last active December 19, 2015 00:09
After upgrading Joomla! through a tool like SPUpgrade or JUpgrade, the component_id might be set wrongfully within the menu-table. leading to Menu-Items that are indicated with a red cross. This script updates the component_id-field with the new component ID.
<?php
// Define variables
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
define('_JEXEC', 1);
define('JPATH_BASE', DOCUMENT_ROOT);
define('DS', DIRECTORY_SEPARATOR );
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null;
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );