How to change increment_idmagento

Just use this SQL query:

UPDATE `eav_entity_store` SET `increment_last_id` = '123456';

This will change last increment_id, may be usefull after restoring backups.

...

Magexim - magento dataflow export/import shell scriptprojects

Export and import your magento store data easier! Just create profile for you needs and use magexim.

Usage: php magexim.php --profile [profile_id]

You can get [profile_id] here: Admin panel -> System -> Import/Export -> Profiles.

See "ID" column

...

Mageorfix - fix orders status in one lineprojects

The easiest way to fix statuses of your orders.

On one of our projects we have very annoying problem - orders statuses. They can be changes by client's managers or as result of erp import, etc.

Some time we need to do these steps to fix order status:

  1. Connect to the production server
  2. Open mysql console
  3. Fix order by this queries:
UPDATE `sales_flat_order` SET `state`='new', `status`='pending' WHERE entity_id=13134;
UPDATE `sales_flat_order_grid` SET `status`='pending' WHERE entity_id=13134;

For each "bugged" order... But now you can do it with a single command:

php mageorfix.php --order 10000431 --status pending

or (with comment):

php mageorfix.php --order 10000431 --status pending --comment "F*cking bug, again!"

Read docs first!

...

Git adviceadvice

  1. Before adding any changes, do git pull --all
  2. If your commit has been rejected from branch (eg: remote branch has some commits ahead your), use #1 and then git push [remote_branch_name]
  3. Before merging (read #5) (eg: from "source" branch to "master" branch) do git pull --rebase origin master (from master branch) and then do git push
  4. Never do commits to the master branch, create new branch for your task, eg: [task#]_test_task
  5. Merge branches with --no-ff argument, eg: git merge 117_importantfix --no-ff
  6. When your closed task (or branch isn't needed more), delete it by git branch -d, eg: git branch -d 116_closedtask. This is safe command - if this branch didn't merged yet, you will be warned.
...

Magedump - Magento tiny db dumperprojects

Here is "tiny" magento database dumper, which ignore tables with logs and lots of unuseful information.

Usage (just use help): php magedump.php -h

Example: Your magento db size is about 1.8-2.0 GB, this script will backup only various info and your backup size will be about 40-45MB gzipped (tested on real-working magento ee shop)

...

How to get bestseller productsmagento

Add this function to the helper of your module (or in any other place):

<?php
    /**
    * Code from http://inchoo.net/ecommerce/magento/bestseller-products-in-magento/
    * @return Mage_Catalog_Model_Resource_Product_Collection Bestseller products collection
    */
    public function getBestsellers()
    {
        $storeId = (int)Mage::app()->getStore()->getId();
        $date = new Zend_Date();
        $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
        $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
        $collection = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
            ->addStoreFilter()
            ->addPriceData()
            ->addTaxPercents()
            ->addUrlRewrite()
            ->setPageSize(6);
        $collection->getSelect()
            ->joinLeft(
                array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')),
                "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'",
                array('SUM(aggregation.qty_ordered) AS sold_quantity')
            )
            ->group('e.entity_id')
            ->order(array('sold_quantity DESC', 'e.created_at'));
        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
        return $collection;
    }
...

How to combine (merge) collectionsmagento

Add this function to the helper of your module (or in any other place):

<?php
    /**
    * Combine 2 collections into 1
    * 
    * This function will join all data from both collections into 1 collection
    * 
    * @param Mage_CatalogSearch_Model_Resource_Advanced_Collection $first First merging collection
    * @param Mage_CatalogSearch_Model_Resource_Advanced_Collection $second Second merging collection
    * @return Mage_CatalogSearch_Model_Resource_Advanced_Collection Combined collection
    */
    public function combineCollections($first, $second)
    {
        $ids = array_merge($first->getAllIds(), $second->getAllIds());
        $newCollection = Mage::getResourceModel('catalog/product_collection')->addFieldToFilter('entity_id', $ids)->addAttributeToSelect('*');
        return $newCollection;
    }
...

How to fix product urlkey (url slug)magento

Hello! Here is code which will fix url key generation for products in magento

You need to do these steps: 1. Create module (google it) 2. Create etc/config.xml:

<?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <Rakshazi_Urlkey>
            <version>0.1.0</version>
        </Rakshazi_Urlkey>
    </modules>
    <global>
        <models>
            <catalog>
                <rewrite>
                    <category>Rakshazi_Urlkey_Model_Category</category>
                </rewrite>
            </catalog>
        </models>
    </global>
</config>
  1. Create Model/Category.php with this content:
<?php
Class Rakshazi_Urlkey_Model_Category extends Mage_Catalog_Model_Category
{
    /**
    * Generating right url key (url slug) for product (support not only latin chars)
    * @param $str string Input string (eg: Product name)
    * @return string Right url key (url slug)
    */
    public function formatUrlKey($str)
    {
        $slug = preg_replace('#[^0-9a-z]+#i', '-', Mage::helper('catalog/product_url')->format($str));
        $slug = strtolower($slug);
        $slug = trim($slug, '-');
        return $slug;
    }
}

That's all!

...

Twitter Bootstrap visual designerbootstrap

Hello!

Today I want to tell you about LayoutIt! - very usefull online service for making bootsrap templates.

...

Installing Blizzard games via Winegames

Hello!

Today I explain you how to install Blizzard games throught Wine (current version is 1.7.x)

...