Coder Social home page Coder Social logo

url-rewrites's Introduction

Magento 1.9 CE Url Rewrite Fix

The issue

Magento 1.9 CE has an url rewrite issue. Magento create the extra entities (duplicates) in 'core_url_rewrite' tables on each reindexing of 'Catalog URL Rewrites'. This Magento module targets this issue and prevents creating duplicates in 'core_url_rewrites' table. However, if you have the running Magento installation, you probably have the duplicates in the database. This repository contains a dedicated Shell script that allows you to remove the duplicates from the database.

Installation

Via git

  • To apply this fix just clone this repository to Magento root directory

Via modman

  • Install modman
  • Use the command from your Magento installation folder: modman clone https://github.com/vladsmirnov/url-rewrites.git

Via Composer

  • Install composer
  • Create a composer.json into your project like the following sample:
{
    "require":{
            "vladsmirnov/url-rewrites":"*"
        },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.firegento.com"
        }
    ]
}
  • From your composer.json folder: php composer.phar install or composer install

Removing duplicates (Shell script usage)

To removing all the extra entities from 'core_url_rewrites' table run this command:

php shell/rewrites.php cleanAll

If you don't want to remove all entities (this makes sense for SEO reasons, since the existing URLs might be cached by search engines) you should use an additional argument --except 'number'. With this additional argument script will delete all records except last 'number' rows.

For example, in this case script will delete all records, except last 5:

php shell/rewrites.php cleanAll --except 5

To get information about script commands run it with 'help' argument:

php shell/rewrites.php help

Contribution

You can contribute by creating the issue or the pull request.

Running the PHPUnit Tests

To run the tests your environment should has the PHPUnit testing framework.

How to install PHPUnit testing framework:

wget https://phar.phpunit.de/phpunit.phar

chmod +x phpunit.phar

sudo mv phpunit.phar /usr/local/bin/phpunit

phpunit --version
PHPUnit 6.4.0 by Sebastian Bergmann and contributors.

phpunit.de - Getting Started with PHPUnit

How to run:

  • Navigate to the test's directory via command:
cd dev/tests/integration 
  • And run:
phpunit

How it works:

After running the tests, will be created 4 test fixture products. Then will be called refreshProductRewrites() method which also calls while running 'Catalog Url Rewrite' reindex. If Magento will create an extra rewrites the test will be failed.

After tests end temp fixture products will be deleted from database.

Authors

This module is developed by Vladyslav Smirnov and Anton Boritskiy.

License

This project is licensed under the MIT License - see the LICENSE file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.