Search by

hryvinskyi / magento2-privacy-consent-import-scommerce

hryvinskyi

One-time import of the Scommerce GDPR consent journal into the privacy consent journal.

Package info

github.com/hryvinskyi/magento2-privacy-consent-import-scommerce

Type:magento2-module

pkg:composer/hryvinskyi/magento2-privacy-consent-import-scommerce

Statistics

Installs: 2

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.1 2026-11-30 20:49 UTC

This package is auto-updated.

Last update: 2026-11-30 20:50:16 UTC


README

A console command that copies the journal of the Scommerce GDPR consent module (the table scommerce_gdpr_consent) into the privacy consent journal, so a store that replaces that module keeps its record of who consented, and when. The command is safe to run again: a second run adds only the rows that were not imported yet. When the import is done the package can be removed, and the imported rows stay.

What it does for a store

  • Imports every row of the old journal. The old module kept one row for each subject and source, with the customer id, the website, the guest's e-mail address, the source, the client address and the date. Each row becomes one given record of the privacy consent journal.

  • Maps each source to a form.

    Old source Form of the new journal Marked unverified
    Contact Us contact no
    Newsletter newsletter no
    Order checkout yes
    Registration registration no

    A row of any other source is counted as skipped, reported by name and not imported.

  • Marks Order rows as unverified. The old module wrote an Order row for every order while its checkout showed no checkbox. Such a row claims a consent but proves no box was shown. The import keeps it, as a record with the unverified flag set. The journal listing in the admin shows the flag and can filter on it, so the rows can be left out of a report or an export.

  • Keeps what the old row held. The record keeps the row's date and its customer. It names the customer only while that customer still exists. The e-mail address is the row's own guest_email, or the customer's address when that field is blank and the customer exists. The core lower-cases it.

  • Puts the row in a store view. The store view is the default store view of the website's default store group. A row whose website no longer exists gets no store view.

  • The client address follows the store view's address mode at the time of the import. The import does not decide how much of an address to keep: it hands the address to the journal, which applies the mode of the row's store view (anonymised, full or none). A store view in the default anonymised mode keeps the network part only, so 203.0.113.77 is stored as 203.0.113.0. A row with no store view is anonymised. Set the mode you want before you run the import: a later change does not touch records already written.

  • Names no consent. An imported record has no consent id and no version, and its consent code is its form code. The journal says imported in the version column.

  • Where the imported rows show. They appear in the admin's journal listing, in the Consents tab of the customer page and in a data export of the subject. They do not appear on the customer's own consents page, because that page lists consents and an imported row names none.

  • Re-runnable. Each row is keyed by its source scommerce and the old row's consent_id. The journal refuses to hold one key twice, and the import reads the keys already present before it writes, so a second run adds only the rows added to the old table in between. Any other write error fails the run with its message instead of being counted as "already imported".

  • The old module can be switched off first. Once no enabled module declares a table, setup:upgrade drops it. This package declares the old journal table, so disabling the Scommerce module, before or after the import, leaves the journal in place for as long as this package is enabled.

  • A dry run changes nothing. --dry-run counts what a real run would add, for each source.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.x. The suite is built and tested on 2.4.9.
  • PHP 8.1 to 8.5.
  • hryvinskyi/magento2-privacy-consent-api ^1.0 and hryvinskyi/magento2-privacy-consent ^1.0.
  • The platform's Store and Customer modules.
  • Nothing of the old module: this package declares the table scommerce_gdpr_consent with the old module's columns, keys and indexes. A store that still has the old journal keeps it, and one that never had it gets an empty table.

Installation

Run from the Magento root. The pack lists this package as a suggestion: install it only for the time of the import.

composer require hryvinskyi/magento2-privacy-consent-import-scommerce
bin/magento module:enable Hryvinskyi_PrivacyConsentApi Hryvinskyi_Clock Hryvinskyi_ClientAddress Hryvinskyi_PrivacyConsent Hryvinskyi_PrivacyConsentImportScommerce
bin/magento setup:upgrade
bin/magento setup:di:compile  # production mode only
bin/magento cache:flush

Verify: bin/magento list privacy-consent shows privacy-consent:import:scommerce.

Running the import

Back up the database first. The real run adds rows to the journal, and the journal is evidence. Check the address mode of every store view (hryvinskyi_privacy_consent/journal/ip_mode) before you start.

  1. Count first. A dry run writes nothing:

    bin/magento privacy-consent:import:scommerce --dry-run

    The output names each source, its form, how many rows the run would add and how many are already imported, then the totals:

    Dry run: nothing is written.
    "Contact Us" (form contact): 2 to add, 0 already imported.
    "Order" (form checkout): 4 to add, 0 already imported.
    Total: 6 to add, 0 already imported, 0 skipped.
    

    The counts above are an example; yours are the old table's.

  2. Import:

    bin/magento privacy-consent:import:scommerce

    The lines read "<source>" (form <code>): <n> added, <m> already imported., and the last line is Total: <added> added, <imported> already imported, <skipped> skipped. A source that is not in the mapping prints "<source>": <n> skipped, the source is unknown.

  3. Run it again to see it holds: the second run adds 0 rows.

The output holds counts and source names only, never an e-mail address or a client address. The command reads the old table in batches of 1000 rows, so memory does not grow with the table.

If the old table was dropped by hand, the command prints The table scommerce_gdpr_consent does not exist. Nothing to import. and exits with success.

Limits

  • The mapping is data, not configuration: the four sources and the Order flag are arguments of Hryvinskyi\PrivacyConsentImportScommerce\Model\RecordConverter in the package's etc/di.xml. A store whose old module used another source name overrides them in its own di.xml.
  • Within a batch, rows are written one source at a time, so the new record ids do not follow the old row order. Every date is kept, and every listing sorts by it.
  • A record imported with the address mode anonymised cannot be restored to a full address later: the original is not kept.
  • The old table's date is a timestamp the database server reads in UTC, and the journal keeps it in UTC.
  • Website 0 (the admin) maps to whatever its group names; the old module wrote such a row only from the admin.
  • Removing the package does not remove the imported rows. It does drop the old journal table when no other enabled module declares it (below).

After the import

The package can be removed. The imported rows stay. The old table scommerce_gdpr_consent is dropped by the setup:upgrade below unless the Scommerce module is still enabled; back the table up first if it must be kept.

bin/magento module:disable Hryvinskyi_PrivacyConsentImportScommerce
composer remove hryvinskyi/magento2-privacy-consent-import-scommerce
bin/magento setup:upgrade
bin/magento cache:flush

Registrations

Where What
Command privacy-consent:import:scommerce [--dry-run], listed in Magento\Framework\Console\CommandListInterface. The import service sits behind a proxy, so another console command does not build it.
Preference …\Model\Store\DefaultStoreOfWebsiteInterface → …\Model\Store\DefaultStoreOfWebsite.
Arguments Model\RecordConverter: formCodes, unverifiedSources. Model\JournalImport: batchSize (1000).

The package declares one table, scommerce_gdpr_consent (the old journal, as the old module declares it). It registers no route, ACL resource, event or layout.

Extension points

None of its own. The rows are written through the core's neutral import contract, Hryvinskyi\PrivacyConsentApi\Api\ConsentRecordImportInterface, which another package can use to import a journal of another source.

Tests

Run from the Magento root.

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/PrivacyConsentImportScommerce/phpunit.xml.dist.
  • Integration: the platform's harness in dev/tests/integration, against its own database, one run at a time. cd dev/tests/integration && php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../app/code/Hryvinskyi/PrivacyConsentImportScommerce/Test/Integration. The tests build a stand-in of the old table.
  • Static analysis: PHPStan 2.x at level 10 with the package's phpstan.neon.dist (phpstan analyse -c app/code/Hryvinskyi/PrivacyConsentImportScommerce/phpstan.neon.dist --level=10), and vendor/bin/phpcs --standard=app/code/Hryvinskyi/PrivacyConsentImportScommerce/phpcs.xml.dist app/code/Hryvinskyi/PrivacyConsentImportScommerce.

Translations

The command's wording ships in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them.