Git Product home page Git Product logo

isabella232 / regenerate-catalog-urls Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elgentos/magento2-regenerate-catalog-urls

0.0 0.0 0.0 69 KB

This extension adds console commands to be able to regenerate; a product rewrite URL based on its url path; a category rewrite URL based on its url path; a category URL path based on its URL key and its parent categories.

License: MIT License

PHP 100.00%

regenerate-catalog-urls's Introduction

What does it do

This extension adds console commands to be able to regenerate;

  • a product rewrite URL based on its url path;
  • a category rewrite URL based on its url path;
  • a category URL path based on its URL key and its parent categories.

Install

Using Composer;

composer require elgentos/regenerate-catalog-urls
php bin/magento setup:upgrade

Or download and copy the Iazel directory into app/code/, enable the module and run php bin/magento setup:upgrade.

How to use

Usage:
 regenerate:product:url [-s|--store="..."] [pids1] ... [pidsN]
 regenerate:category:url [-s]--store="..."] [cids1] ... [cidsN]
 regenerate:category:path [-s]--store="..."] [cids1] ... [cidsN]

Arguments:
 pids                  Products to regenerate
 cids                  Categories to regenerate

Options:
 --store (-s)          Use the specific Store View (default: 0)
 --help (-h)           Display this help message

Eg:

# Regenerate url for all products and the global store
php bin/magento regenerate:product:url

# Regenerate url for products with id (1, 2, 3, 4) for store 1
php bin/magento regenerate:product:url -s1 1 2 3 4

FAQ

What's the difference between url_key and url_path?

url_key contains the key, like joust-duffle-bag for the product "Joust Duffle Bag". The url_path is generated by taking the url_key and adding the suffix (which for products is stored in catalog/seo/product_url_suffix and defaults to .html). So the url_path would by default become joust-duffle-bag.html. It also adds the category slugs of the parent categories so the url_path might become bags/joust-duffle-bag.html. However, the use of url_path has been deprecated since early Magento 2.1 versions (see here). If you are running on a recent Magento 2 version, you can safely delete those values by running DELETE FROM catalog_product_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_path' AND entity_type_id = 4).

Why are my category rewrites for a non-default storeview in the default storeview's language?

This is probably due to url_path values in the database. Since these aren't updated anymore, but they are still present, the data may be out of sync. See these issues. The easiest fix is to delete the url_path values from the database (only if you are running >2.1). Here's a quick query; DELETE FROM catalog_category_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_path' AND entity_type_id = 3);.

Why am I getting a 'Duplicated url' warning when running the command?

If you see this error, you have duplicate url_key values (within a store) in catalog_product_entity_varchar. You can use this extension to check those (and you need to fix them manually): baldwin/magento2-module-url-data-integrity-checker.

regenerate-catalog-urls's People

Contributors

peterjaap avatar amenk avatar wouter-toppy avatar iazel avatar flancer64 avatar barryvdh avatar davidlambauer avatar danielimi avatar php4umagento avatar

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.