Giter Site home page Giter Site logo

Comments (8)

gjportegies avatar gjportegies commented on May 30, 2024 1

Hi @patrick-bigbridge

Just updated to 1.5.0 added the line $this->importConfig->categoryStrategy = ImportConfig::CATEGORY_STRATEGY_SET;

and...

it worked perfectly! 🚀
Big thanks.

from product-import.

patrick-bigbridge avatar patrick-bigbridge commented on May 30, 2024

Hi Guus,

Nice to hear that the import works well, thanks!

As for your question: the importer does not remove existing product-category connections, because I considered this to be too dangerous. After a product is imported, it is often connected to extra categories, like "sale", or "new" by the shop owner. These connections would be removed if the importer replaces all product-category connections, and this error has a high chance of occurrence, in my view.

I could probably say more about this, but for the moment this answers your question, and if you have further answers or requests I will be happy to respond to them. :)

from product-import.

gjportegies avatar gjportegies commented on May 30, 2024

Hi Patrick,

Thanks for the quick answer.
I totally agree with your answer and therefore design choices; I think my use case is also very specific because the products only appear in a single category. I'll just fork the repository and adjust and'll try to change it for my use case but thought it might be useful for others with a configuration option as something like 'replaceCurrentCategories = false' or with a custom method 'replaceCategoryIds()'.

from product-import.

patrick-bigbridge avatar patrick-bigbridge commented on May 30, 2024

Hi,

In fact, you are the second person to bring up this issue to me. So there is some demand for it, and I am willing to add this as an option. If the danger is documented properly it could be used in the cases where it is needed and can be implemented safely. The config would then look like this (compare to $imageStrategy)

/**
     * How to deal with the imported categories?
     * - add: link products to categories named in the import
     * - set: like add, but delete existing links that are not named in the import
     * 
     *  Important! When using 'set', consider the possibility that the shop owner may link products to categories that are not part of the import, such as "new" or "sale"; those products will be removed from these categories by the import!
     *
     * @var string
     */
    public $categoryStrategy = self::CATEGORY_STRATEGY_ADD;

    const CATEGORY_STRATEGY_ADD = 'add'; // Only add and update category links
    const CATEGORY_STRATEGY_SET = 'set'; // Add and update category links; and also remove existing category links not named in the import

(note that it updates category links, not categories)

The best thing would be to have 'set' remove only category-links that have been added by the import. To distinguish between import-links and non-import links. I can think of ways to do this, but they don't strike me as very elegant (storing all links in a new table). So if someone has a good idea for this, I would like to hear it :)

Guus, if you have already made this change, I would like to ask you to make a pull request. Otherwise I will program this myself.

from product-import.

patrick-bigbridge avatar patrick-bigbridge commented on May 30, 2024

Yes, I will have a go at this feature myself. I will let you know about the progress.

from product-import.

gjportegies avatar gjportegies commented on May 30, 2024

Sorry, for the late reply @patrick-bigbridge, had my answer ready but somehow forgot to comment it. I didn't made any changes yet but I'm very willing to help or contribute in any way.

The config approach looks very solid. But just like you said, it should be documented properly and shouldn't change the current behaviour. Sidenote for the documentation; I found your explanation about product that are often assigend to extra categories like "new" and "sale" very clear.

Edit: I see you already wrote a very clear comment in the above example.

from product-import.

patrick-bigbridge avatar patrick-bigbridge commented on May 30, 2024

Hi @gjportegies

No problem.

I just released 1.5.0 that has this option.

$config->categoryStrategy = ImportConfig::CATEGORY_STRATEGY_SET

It does not change current behaviour, it just adds some. It carefully calculates which links need to be removed, and removed only these. I made sure that if you don't import categories at all, that no categories are removed.

from product-import.

gzumaglini avatar gzumaglini commented on May 30, 2024

I have problems using CATEGORY_STRATEGY_SET in a Multi-Store Setup.

Scenario:

  • SHOP A

    • SKU X is in Categories CATEGORY 1, CATEGORY 2, CATEGORY 3, CATEGORY 4
  • SHOP B

    • SKU X is in Categories CATEGORY 1, CATEGORY 2

SKU X is available in both Shops but can be in different Categories.
Btw. the Shops use different Category Trees but Categories are named the same in both Shops.

If i Import the Products for Shop B the Product is removed from CATEGORY 3 and CATEGORY 4 in Shop A.

Is this a bug or am i thinking wrong?

from product-import.

Related Issues (20)

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.