Comments (6)
Yes, you are right. Thanks for reporting it. There's a bug in the creation of categories. The "level" field catalog_category_entity is set 1 too high. Also the "position" of the new category within the parent category is not calculated right, but that's probably not so important.
I would like to make the following changes to fix this, can you check for me if this helps, before I create a new release:
The function now starts with
$categoryEntityTable = $this->metaData->categoryEntityTable;
$urlRewriteTable = $this->metaData->urlRewriteTable;
$attributeSetId = $this->metaData->defaultCategoryAttributeSetId;
$parentLevel = count($idPath) - 1;
$childLevel = $parentLevel + 1;
$parentId = $idPath[$parentLevel];
$parentPath = implode(self::CATEGORY_ID_PATH_SEPARATOR, $idPath);
// update parent data
$this->db->execute("
and in the calculation of $position a bit below that in the same function
$position = $this->db->fetchSingleCell("
SELECT MAX(`position`)
FROM `{$categoryEntityTable}`
WHERE `path` LIKE ? AND level = ?
", [
"{$parentPath}/%",
$childLevel
]);
Note that $parentLevel was changed to $childLevel
from product-import.
Hey sorry for the slow response, github didn't notify me that you replied. As I was testing the update I forgot that I should mention there's a trimming issue. I'm using CData to pass some special values into the category & description. XML does not like these values. Anyways, when being passed using CData it adds a random whitespace in front of the category.
In the ElementHandler.php
I changed line 395 to
$value = trim($this->characterData);
Line 406 to
$this->product->addCategoriesByGlobalName(array_map('trim', $this->items));
To remove any additional whitespacing. I'm still in the process of testing, just figured I post this now before I forget.
Update:
Your solution above fixed the level and position issue. I might need to mention that when deleting the categories from admin and importing using the script, the children count gets messed up. Doesn't seem to be such a big issue for me at least.
While I have you here, I was hoping I could get off topic a little and pick your brain a little in regards to pointing my images to an AWS S3 bucket. There's currently another bug where the product images don't get deleted when removing them from the XML. I had to manually remove the item and repopulate for it to have the correct images.
I'm going to store everything on S3 and run a cdn to cache all my images. Any chance you would know how to send me in the right direction? I'm currently hosting the images locally and I believe I can shave import time, space, and cost if I just point everything to S3.
My current benchmark is 2 minutes for 10k items. (I will have over 1 million items hopefully when I'm done populating)
I'm hoping in the future I will allow the API to accept a JSON body just for my personal preference.
from product-import.
No need to apologize for a slow response. I am not in a hurry ;)
Thanks for showing the missing trim(). Only I will place it in the Product and ProductStoreView classes for this use is more general. I noticed more trims were needed there as well.
I hope you find some more bugs. Name them here and when you're done I will create a single new release.
I need some more information if you want to have the image to be deleted. Are you using the ImportConfig::$imageStrategy 'set', for instance?
Check ImportConfig::$existingImageStrategy for options you can use to import images from remote locations.
from product-import.
When you import from a remote location, I believe it downloads it and then caches it locally correct? If so, that may defeat the purpose of me storing it in S3. I am hoping to run all my product images off S3 to share across other platforms.
As far as the images, I am just repopulating the xml file with just list of images removed/added. I am hoping this importer can serve as a lightweight inventory stock updater.
And I will keep an eye on more bugs! I hope to use this in production sometime this week. Working out all the kinks, but it's been a great extension so far.
from product-import.
Hi @choleaoum
I am planning to close this issue and create a new release for the fixes. Is there anything you would like to add?
from product-import.
I created a new release and close this issue.
from product-import.
Related Issues (20)
- 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
- Can't set is_in_stock = 0 HOT 1
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.