Comments (8)
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.
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.
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.
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.
Yes, I will have a go at this feature myself. I will let you know about the progress.
from product-import.
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.
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.
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)
- How to use --url-key-strategy. HOT 4
- website_codes restapi HOT 4
- How to use the programming library to import products HOT 3
- Restapi update url issue HOT 15
- Category flat url structure HOT 9
- Image import creates hardlinks HOT 9
- Please provide example of how to use post method with webapi? HOT 11
- Saving product on storeview scope overwrites storeview attribute values with global values HOT 4
- How to set salable quantity ? HOT 5
- Export category attribute values HOT 2
- Trying to get property 'path' of non-object in Model/Resource/Storage/UrlRewriteStorage.php on line 376 HOT 1
- How to set out of stock threshold for backorders ? HOT 4
- Importing library fails after clearing all products HOT 1
- The setSelectAttribute method does not fill swatch input on Text Swatch HOT 3
- Module shouldn't rely on magento2-base package to exist HOT 3
- Fetching Magento configurations isn't working as expected HOT 3
- Generated Url key already exists HOT 1
- Clear Cache after change per product ID HOT 1
- PHP 8 Compatibility HOT 1
- Choose Affected Attribute Set prompt when saving configurable product
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from product-import.