Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX : 14958 - sales sequence store delete #18466

Closed
wants to merge 2 commits into from
Closed

FIX : 14958 - sales sequence store delete #18466

wants to merge 2 commits into from

Conversation

benjamin-volle
Copy link

Description

sale_sequence_* records are not removed on store view deletion

Fixed Issues (if relevant)

#14958

Manual testing scenarios

  1. Create store view, it generated sequences_* tables
  2. Delete the store view, the linked lines/tables are deleted

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the review comments. Also, the implementation is removing rows only from the sales_sequence_profile table, please consider removing corresponding rows from sales_sequence_meta as well to provide a complete fix for the issue #14958

@@ -51,6 +51,9 @@
<event name="store_add">
<observer name="magento_sequence" instance="Magento\SalesSequence\Observer\SequenceCreatorObserver" />
</event>
<event name="store_delete">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the functionality is on SalesSequence module side, this event configuration should be moved to that module as well

$select = $connection->select()
->from($this->getMainTable(), ['profile_id'])
->where('meta_id = :meta_id')
->where('is_active = 1');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that non-active profiles should be removed as well in case of store delete


$profileIds = $this->resourceProfile->getProfileIds($metadata->getId());

foreach ($profileIds as $profileId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove all profiles with a single query. Is there a way to do so?

public function execute(EventObserver $observer)
{
$storeId = $observer->getData('store')->getId();
foreach ($this->entityPool->getEntities() as $entityType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be better from a performance point of view to load all meta_ids using a single query, also entityType is not really required for this operation, as the delete operation is performed for all the entity types

@sivaschenko
Copy link
Member

Hi @synolia-bvo , would you like to continue work on this PR?

@sivaschenko
Copy link
Member

@synolia-bvo closing due to inactivity. Feel free to contact me if you'd like to continue work on this contribution.

@benjamin-volle benjamin-volle deleted the fix/14958-sales-sequence-store-delete branch September 29, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants