Skip to content

Scripts to create nginx redirects from magento to shopware product (and other) URLs

License

Notifications You must be signed in to change notification settings

rawliving-germany/magento_shopware_redirects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

magento-shopware-redirects

Scripts to create redirect definitions for nginx from magento 2 URLs to shopware 5 URLs. As the script is tied to one specific migration, a number of magento settings are assumed. Within magento there are multiple ways to influence the generated urls (SEO etc.). The value of these settings are totally ignored.

Ideally, you would iterate over the sitemap, but apparently in our use case the sitemap generation is messed up.

Magentos URLs reflect the productId in our case, but we have access to the SKU.

It will only work with MySQL/MariaDB installations.

Scope

Following URLs should be redirected:

However, admin-access path should NOT be redirected.

Usage

run magento_shopware_redirects --help

It is assumed that magento and shopware share the same database server.

Knowledgebase

Memstore

A stupid multi-index memory store is implemented in lib/memstore.rb . Some basic tests included in test/.

The idea is to keep hashtables that allow quick access to objects by attribute, think of half-memoized objects.select{|obj| obj.attribute == attribute_value}. Alternative would be an external dependency and e.g. an in-memory sqlite3 or berkely-db.

Database

Infos in Magento DB

  • sku in catalag_product_entity
  • there are shortforms of the articles in two varchar eav-attributes
  • specific product URLs in eav_attributes url_key and url_path.
    • per product: catalog_product_entity_varchar (.value) where attribute_id matches these and entity_id matches the products entity_id

Infos in Shopware DB

  • sku is in s_articles_details (articleID / ordernumber)
  • (relative) product URLs are in s_core_rewrite_urls, but need to be downcased. Find from product id via org_path (e.g. sViewport=detail&sArticle=122).
  • configurable articles have multiple s_article_details for the same articleId

"Architecture"

(There was no prior architectural work, so this is rather a "what grew where"):

Code map

.
├── lib
│   ├── db_credentials.rb            # PORO for the two DB credentials
│   ├── db.rb                        # DB driver (mysql shim) and base class
│   ├── magento_db.rb                # Queries against magento DB and memstore
│   ├── magento_shopware_redirect.rb # Module-wide functionality and conf
│   ├── memstore.rb                  # in-mem selfbuild multi-directional cache
│   ├── product.rb                   # Class for in-mem abstraction of a Product
│   ├── product_redirects.rb         # Per Product Nginx redirect rule strings
│   ├── shopware_db.rb               # Queries against shopware DB and memstore
│   └── static_redirects.rb          # Static (non-product) redirect rule(s)
├── magento_shopware_redirects.rb    # MAIN entry/script/exec
└── test                             # Tests
    └── test_memstore.rb             # Memstore Test

License

Code is copyright 2021,2022 Felix Wolfsteller and released under the AGPLv3+ which is included in the LICENSE file in full text. The project should become reuse compliant.

However, these are only notes and scripts for a specific usecase. If you have a (tiny) budget and need or some ideas about improvements, just get in contact.

About

Scripts to create nginx redirects from magento to shopware product (and other) URLs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages