magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Error when updating category scheduled changes for a specific store view #37210

Closed GioDeGruyter closed 1 year ago

GioDeGruyter commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Navigate to Catalog > Categories in the admin section
  2. Change the scope to a specific store view
  3. Select any category
  4. Create a new scheduled change for the category for the specific store view
  5. Save the schedule and the category
  6. Update the existing schedule, change the end date of the existing schedule and try to save it

Expected result

The schedule is saved.

Actual result

The following error occurs:

image

Additional information

I was able to reproduce this issue on a clean 2.4.5-p1 installation with sample data.

The following log regarding the issue can be found in system.log:

[2023-03-14T20:52:30.453553+00:00] report.CRITICAL: Exception message: Warning: Undefined array key "updated_in" in /app/vendor/magento/module-staging/Model/Operation/Update.php on line 174

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @GioDeGruyter. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


engcom-Dash commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash, here is your Magento Instance: https://2ceca0a462e3e51cede05847dd3e46e2.instances-prod.magento-community.engineering Admin access: https://2ceca0a462e3e51cede05847dd3e46e2.instances-prod.magento-community.engineering/admin_4a1e Login: f9a184d1 Password: daf0fdc0edea

engcom-Dash commented 1 year ago

Hi @GioDeGruyter ,

Issue confirmed !

Verified the issue in 2.4-develop instance and the issue is reproducible,Hence we are confirming the issue.

Preconditions:

Magento Version 2.4-develop PHP Version 8.1 Multi store was created

Steps to reproduce:

Kindly Refer the below screenshots:

st1 st2 st3 st4 st6

We are trying to Update the existing schedule(change the end date of the existing schedule and try to save it),But we getting the error which is attached in above screenshot also we are getting same system.log as per the description and system.log screenshots also attached.This is actual result,So we are confirming the issue in 2.4-develop instance.

Regards,

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-8256 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Dash. Thank you for verifying the issue.
Issue Available: @engcom-Dash, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

GioDeGruyter commented 1 year ago

Are there any updates revolving this issue?

vacla commented 1 year ago

Is there any update on this, or is there maybe already a patch available that we are able to apply to go around this?

engcom-Dash commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash, here is your Magento Instance: https://2ceca0a462e3e51cede05847dd3e46e2.instances-prod.magento-community.engineering Admin access: https://2ceca0a462e3e51cede05847dd3e46e2.instances-prod.magento-community.engineering/admin_a678 Login: 58a36755 Password: 0d0062a74fc4

engcom-Dash commented 1 year ago

@magento give me 2.4-develop commerce instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Dash, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

engcom-Dash commented 1 year ago

Hi @GioDeGruyter ,

I tried to reproduce the issue on the latest code base of 2.4-develop with multiple store views enabled, but was unable to do so. Here are the steps followed,

Navigate to Catalog > Categories in the admin section Change the scope to a specific store view Select any category Create a new scheduled change for the category for the specific store view Save the schedule and the category Update the existing schedule, change the end date of the existing schedule and try to save it imageimage

This issue is no longer reproducible,Hence we are closing this issue.

Let us know if we are missing anything!

Regards,

GioDeGruyter commented 1 year ago

@engcom-Dash What is the upcoming release on the 2.4 develop branch? And is there a possibility we can patch this for our current version?

Planet9store commented 1 year ago

@magento-admin I am encountering an issue related to "Error when updating category scheduled changes for a specific store view" in Magento. Are there any relevant patches available to address this problem? The required version is 2.4.5-p1

GioDeGruyter commented 1 year ago

@magento-admin Could we reopen this issue? Since this has clearly not been fixed yet.

bona-kim commented 1 year ago

@magento-admin I've tested on 2.4.6 enterprise clean environment but the issue is still there. Could you retest and reopen the issue?

Screenshot 2023-07-27 at 09 19 37 Screenshot 2023-07-27 at 09 16 12
GioDeGruyter commented 1 year ago

@magento-admin Any updates on this? Could this be reopened as @bona-kim asked?

SandraKot commented 1 year ago

@magento-admin This seems to be issue as well on 2.4.5-p3, we get the same problem 'error: : Something went wrong while saving the Magento\Catalog\Api\Data\CategoryInterface.'

And then in logs: report.CRITICAL: Exception: Warning: Undefined array key "updated_in" in /app/vendor/magento/module-staging/Model/Operation/Update.php on line 174 in /app/vendor/magento/framework/App/ErrorHandler.php:62

monarch-sp commented 1 year ago

After spending an hour digging into the code, I have identified the issue. It appears that the problem lies within the 'vendor/magento/module-staging/Model/Operation/Update.php' file

Override the 'vendor/magento/module-staging/Model/Operation/Update.php' file in your module

Add

$version = $this->versionInfoProvider->getVersionInfo(
            $entity,
            $this->resolveVersion(array_merge($entityData, $arguments))
            );
         $entityData['updated_in'] = $version->getUpdatedIn();

in processUpdate function

code should be.

private function processUpdate(
        EntityMetadataInterface $metadata,
        $entityType,
        $entity,
        $arguments
    ) {

if (isset($arguments['origin_in'])) {
             $version = $this->versionInfoProvider->getVersionInfo(
            $entity,
            $this->resolveVersion(array_merge($entityData, $arguments))
            );
         $entityData['updated_in'] = $version->getUpdatedIn();
            $needReschedule = $arguments['created_in'] != $arguments['origin_in']
                || $update->getRollbackId() != $entityData['updated_in'];
                ....
                ...
linetsoscar commented 1 year ago

After spending an hour digging into the code, I have identified the issue. It appears that the problem lies within the 'vendor/magento/module-staging/Model/Operation/Update.php' file

Override the 'vendor/magento/module-staging/Model/Operation/Update.php' file in your module

Add

$version = $this->versionInfoProvider->getVersionInfo(
            $entity,
            $this->resolveVersion(array_merge($entityData, $arguments))
            );
         $entityData['updated_in'] = $version->getUpdatedIn();

in processUpdate function

code should be.

private function processUpdate(
        EntityMetadataInterface $metadata,
        $entityType,
        $entity,
        $arguments
    ) {

if (isset($arguments['origin_in'])) {
             $version = $this->versionInfoProvider->getVersionInfo(
            $entity,
            $this->resolveVersion(array_merge($entityData, $arguments))
            );
         $entityData['updated_in'] = $version->getUpdatedIn();
            $needReschedule = $arguments['created_in'] != $arguments['origin_in']
                || $update->getRollbackId() != $entityData['updated_in'];
                ....
                ...

COuld you share the way how did you fix it? i did the same thing as you, but still getting that error, please.

GioDeGruyter commented 1 year ago

We had the same issue @linetsoscar. We've resolved it by setting the updated_in data on the entity itself as well:

$entity->setData('updated_in', $version->getUpdatedIn());

This results into:

private function processUpdate(
        EntityMetadataInterface $metadata,
        $entityType,
        $entity,
        $arguments
    ) {

if (isset($arguments['origin_in'])) {
             $version = $this->versionInfoProvider->getVersionInfo(
            $entity,
            $this->resolveVersion(array_merge($entityData, $arguments))
            );
         $entityData['updated_in'] = $version->getUpdatedIn();
         $entity->setData('updated_in', $version->getUpdatedIn());
            $needReschedule = $arguments['created_in'] != $arguments['origin_in']
                || $update->getRollbackId() != $entityData['updated_in'];
                ....
                ...
linetsoscar commented 1 year ago

Thank u @GioDeGruyter but i still have the problem, it is not redirecting, the loading spinner doesnt disappear, but it is updating which is ok... isnt it happening in your case?

linetsoscar commented 1 year ago

Here i have an image in order to show u that the spinner still showing, and i checked the logs and no errros reported. Screenshot from 2023-09-01 15-23-45

mamsincl commented 9 months ago

duplicated on Adobe Commerce 2.4.6-p3 with for All Store View (store_id 0)


fix we come up


diff --git a/vendor/magento/module-staging/Model/Operation/Update.php b/vendor/magento/module-staging/Model/Operation/Update.php
index 76a8b5bf..cbe8bbf8 100644
--- a/vendor/magento/module-staging/Model/Operation/Update.php
+++ b/vendor/magento/module-staging/Model/Operation/Update.php
@@ -168,6 +168,14 @@ class Update implements UpdateInterface
         }
         $update = $this->updateRepository->get($arguments['created_in']);

+        $version = $this->versionInfoProvider->getVersionInfo(
+            $entity,
+            $this->resolveVersion(array_merge($entityData, $arguments))
+        );
+        if (!isset($entityData['updated_in']) && $version->getUpdatedIn()) {
+            $entityData['updated_in'] = $version->getUpdatedIn();
+        }
+
         $needReschedule = false;
         if (isset($arguments['origin_in'])) {
             $needReschedule = $arguments['created_in'] != $arguments['origin_in']
@@ -178,10 +186,6 @@ class Update implements UpdateInterface
         }

         $identifier = $entityData[$metadata->getIdentifierField()];
-        $version = $this->versionInfoProvider->getVersionInfo(
-            $entity,
-            $this->resolveVersion(array_merge($entityData, $arguments))
-        );
         if ($version->getRowId() != null) {
             if ($update->getRollbackId()) {
                 $arguments['updated_in'] = $update->getRollbackId();

just dug a bit deeper, will testing https://experienceleague.adobe.com/docs/commerce-knowledge-base/kb/support-tools/patches/v1-1-35/acsd-51358-schedule-updates-are-missing.html?lang=en as a resolution to our problem