chaddro / EasyPopulate-4.0

Data import and export module for Zencart 1.3.x and 1.5.x
GNU General Public License v2.0
24 stars 31 forks source link

Category Import don´t support Subcategories #33

Closed Richie76 closed 3 years ago

Richie76 commented 7 years ago

Hi,

I exported my categories and re-imported them. My expectation was that nothing will happen cause I haven´t altered the file. But after the Import I had all subcategories added right next to the main categories.

It seems that the SQL "parent_id" is not exported - therefore the import does not have any information about the structure of the categories. I have looked a bit on the code here but I´m not a good programmer so I couldn´t find the point where this is missing.

Rgds, Richard

mc12345678 commented 7 years ago

Which category export? Also please confirm the version number of EP4 as reported on the admin screen. As to "parent", that is typically addressed/controlled through the category assignment through the product full area with the assignment of sub-category to category and as necessary creation of new categories.

Richie76 commented 7 years ago

Version: Easy Populate 4.0.36.ZC - 07-05-2016 (pulled 2 days ago of off github here)

Clicking on the "Categories Only (with Metatags)" link and downloading the file which was created.

There is no information about which category is a subcategory or not in this file. So when you click on "Import" (file is located below the "Prefix: categorymeta-ep. They will be processed through the Category Meta filters.") it messes up your category. Each subcategory is now listed as a main category - which is quite annoying. In the database subcategories have a "parent_id" which represents their specific order inside the structure. This is not exported and therefore each category is added to the top level when importing. So just maybe place a warning there to not import those files.

If you add products with the "Full" Import - all categories are added as it should be - or products are added if the category existed.

I hope I explained what my "problem" is. Just the CategoryMeta export and import.

Rgds, Richard

mc12345678 commented 7 years ago

The filename was sufficient. I did see that the categoryMeta only exported the category name and did not "display" like it does when exporting with Full Product etc. I will need to look at what I did to this subsection as I don't recall others having reported a similar problem before I started making some significant changes. Again thank you for the assistance/clarification.

mc12345678 commented 7 years ago

I'm not seeing how this would happen of where the category meta file is exported, the file remains on the server, the first 15 characters of the filename have not been changed away from some capitalization version of categorymeta-ep, then imported to cause anything but an update to the category data which does not touch/affect the category's parent.

The only way that the category information could become a plain category and lose its structure is if the filename was changed to something other than the following that begin with the provided filename "part": Categorymeta-ep Attrib- Sba- (if stock by attributes is identified as installed, otherwise files beginning with sba- would be processed as described.

That said, I do see that the hidden field 'import' is set to be the urlencoded version of $file['name'] and then that becomes the post data to be interpreted when importing data. Therefore if the prefix of the filename after it has been urlencoded is not categorymeta-ep then the result you are seeing is expected.

Suggestion to try is the following: In: admin/easypopulate_4.php Find all (7 cases matter, 2 are commented out) urlencode Replace with: rawurlencode Then in: admin/easypopulate_4_import.php On line 17, modify the right side of the array from: $_POST['import'] To: rawurldecode($_POST['import'])

chaddro commented 7 years ago

hey chad,

I don’t remember so well as it has been ages since I looked at this code, but if my memory is correct, the category export was only to be used to update category info (like images and description).

It was not supposed to alter the structure of the categories. The key if I remember correctly, is the internal category id…

I don’t know if this will be any help or not, hopefully it will.

-chadd

On Apr 17, 2017, at 8:44 AM, mc12345678 notifications@github.com wrote:

I'm not seeing how this would happen of where the category meta file is exported, the file remains on the server, the first 15 characters of the filename have not been changed away from some capitalization version of categorymeta-ep, then imported to cause anything but an update to the category data which does not touch/affect the category's parent.

The only way that the category information could become a plain category and lose its structure is if the filename was changed to something other than the following that begin with the provided filename "part": Categorymeta-ep Attrib- Sba- (if stock by attributes is identified as installed, otherwise files beginning with sba- would be processed as described.

That said, I do see that the hidden field 'import' is set to be the urlencoded version of $file['name'] and then that becomes the post data to be interpreted when importing data. Therefore if the prefix of the filename after it has been urlencoded is not categorymeta-ep then the result you are seeing is expected.

Suggestion to try is the following: In: admin/easypopulate_4.php Find all (7 cases matter, 2 are commented out) urlencode Replace with: rawurlencode Then in: admin/easypopulate_4_import.php On line 17, modify the right side of the array from: $_POST['import'] To: rawurldecode($_POST['import'])

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chaddro/EasyPopulate-4.0/issues/33#issuecomment-294488143, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKxOnPStC3Un5HRDSFjBeW0coPb_HcOks5rw2zYgaJpZM4M-t99.

mc12345678 commented 7 years ago

the category export was only to be used to update category info (like images and description). It was not supposed to alter the structure of the categories. The key if I remember correctly, is the internal category id…

That was the basis for my comment(s) above and why I wanted to look to see if I had modified something that would cause the categorymeta-ep file to be treated any differently than described in your paragraph. The only thing that I saw was related to the difference of using a POST instead of GET to provide the filename. None of the characters used should have been "translated" because there are no special characters unlike when/if Maer is used in lieu of Mar (German "spelling" of March) which if used by the system would modify the "filename" to the right but should have no affect on the prefix. Not to mention that the file selected showed in the correct file location.

So there is some "abnormality" between "normal" setup and this system, but in review of the code on the import file, if the file gets processed as a categorymeta-ep file then it doesn't cause the categories to try to be pushed to the root of the store as was seen/explained.

mc12345678 commented 7 years ago

@Richie76, did the above code change make a difference in the results?

I am considering changing the title of this issue because as pointed out, the category import/export is not intended to designate the relationship of one category to another nor to generate new categories but to assign data associated to the existing category data.

Richie76 commented 7 years ago

Hi there,

Since I´ve populated my shop in the meantime I am not too eager to play around with this anymore. Also I haven´t tested your suggestion (was busy populating the shop).

If i have time I´ll setup a test and try it.

Rgds, Richard

mc12345678 commented 3 years ago

Closing this (at least temporarily) as no further reports in 4 years.