Allow products to be duplicated

Created on 22 March 2019, almost 6 years ago
Updated 24 December 2023, about 1 year ago

Once #3042257: Allow stores, promotions to be duplicated is done, we can proceed to products.

The simplest implementation would remove all referenced variations in createDuplicate(), since variations can't be shared between products and they have unique SKUs. However, we can implement an optimization for single-variation products ($product_type->allowMultipleVariations() is FALSE), and clone the variation in that case (since we know that the SKU field will be shown along with the product form).

Also, feedback suggests we need a way to duplicate variations as well. If we proceed without it, we should open a followup.

Feature request
Status

Needs review

Version

2.0

Component

Product

Created by

🇷🇸Serbia bojanz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Pipeline finished with Skipped
    about 1 year ago
    #56315
  • Merge request !212Resolve #3042258 "Allow products to duplicate" → (Open) created by abx
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    777 pass, 4 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    790 pass
  • Pipeline finished with Canceled
    about 1 year ago
    Total: 417s
    #68011
  • Pipeline finished with Failed
    about 1 year ago
    Total: 440s
    #68015
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    791 pass
  • Attaching a patch based on #24 for 2.37

  • 🇮🇱Israel jsacksick

    Main thing I'm worried about here is duplicating a product with thousands of variations... Even though that concern is also valid for the Product::postSave() logic as we loop over all variations there... This potentially has to be improved btw...

  • Main thing I'm worried about here is duplicating a product with thousands of variations

    This probably is a more general issue, as you mentioned, and maybe it's best to be tackled on a separate issue.

    This potentially has to be improved btw

    +1

  • 🇺🇸United States rhovland Oregon

    rhovland changed the visibility of the branch 3042258-allow-products-to to hidden.

  • 🇺🇸United States rhovland Oregon

    rhovland changed the visibility of the branch 3042258-allow-products-to to active.

  • 🇺🇸United States rhovland Oregon

    One bug we noticed today: The created time of the old product gets duplicated. The creation time should be set to when the duplicate is created.

  • Status changed to Needs work 6 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    +1 on this feature! Setting to NW based on #30

  • 🇺🇸United States rhovland Oregon

    rhovland changed the visibility of the branch 3.0.x to hidden.

  • Pipeline finished with Failed
    4 months ago
    Total: 541s
    #313338
  • 🇺🇸United States rhovland Oregon

    Created a new branch for 3.0.x. Attempted to address the creation time issue.

  • 🇺🇸United States rhovland Oregon
  • Status changed to Needs review about 1 month ago
  • 🇳🇱Netherlands flink den haag

    I am uncertain this is within the scope of this issue, but i use this module in combination with the paragraphs module. It seems currently that if you have a product with a paragraph field and a paragraph and then clone this product. The exact same paragraph is copied to the cloned product. Resulting in a situation where if you change anything in one product the clone changes too because its the exact same paragraph instead of a new paragraph with the copied information. The quick node clone module does have support for this so maybe this is something that can be copied. Their solution is to loop through all fields and for all paragraph reference fields to then call entity::createDuplicate and then bind this to the field.

  • I am uncertain this is within the scope of this issue, but i use this module in combination with the paragraphs module. It seems currently that if you have a product with a paragraph field and a paragraph and then clone this product. The exact same paragraph is copied to the cloned product. Resulting in a situation where if you change anything in one product the clone changes too because its the exact same paragraph instead of a new paragraph with the copied information. The quick node clone module does have support for this so maybe this is something that can be copied. Their solution is to loop through all fields and for all paragraph reference fields to then call entity::createDuplicate and then bind this to the field.

Production build 0.71.5 2024