Skip to content

Proposal: optional integration to compare item prices with supermarkets (Argentina only) #4807

Open

Description

@hernanmardel

Hi! I run Lista Inteligente, a free price-comparison app in Argentina. It compares supermarket prices published daily through the government's official price program (Precios Claros / SEPA) with prices from neighborhood stores. Many small stores here use OSPOS.
I'd like to contribute a small, optional feature before writing a PR, and wanted to ask whether it would be welcome:
A "Compare with supermarkets" button in Items, shown only when the store is configured for Argentina (currency_code = ARS or an America/Argentina timezone). Nothing changes for anyone else.
On first use it asks for explicit consent, then sends only barcode, item name and final retail price of active items. No costs, stock, customers or sales.
It opens a page with the store's prices compared against supermarkets in their province. Publishing them in the app is a separate, opt-in step.
Self-contained: one controller method, one helper, a button in items/manage, and language strings (es, en).
It's already working on 3.4.3 in a test install. Would you consider merging something like this, perhaps behind a config switch? Happy to adapt it to your conventions.

Activity

  1. jekkos commented on Nov 10, 2026

    @jekkos
    Member

    Hi it might be a useful additionele but best to add it as a plugin as it does not really belong to the core functionality. The plugin PR is mostly ready and will be merged once we pushed out a last minor release with fixes in master. #4407 check documentation in the PR on how to setup the plugin structure

  2. hernanmardel commented on Nov 10, 2026

    @hernanmardel
    Author
  3. jekkos commented on Nov 11, 2026

    @jekkos
    Member

    @CodeRabbit can you dit this up from the conversation

  4. coderabbitai commented on Nov 11, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    set -u
    echo '=== issue 4807 ==='
    gh issue view 4807 --repo opensourcepos/opensourcepos --json number,title,body,state,url
    for pr in 4255 4407; do
      echo "=== PR $pr metadata ==="
      gh pr view "$pr" --repo opensourcepos/opensourcepos --json number,title,body,state,mergedAt,headRefName,headRefOid,baseRefName,url,files
    done
    echo '=== Named files and directories ==='
    fd -H -t f '^Events\.php$' . || true
    fd -H -t d '^Plugins$' . || true
    echo '=== Current event registration and plugin references ==='
    rg -n -C 2 'item_change|Events::on|Events::trigger|Mail[Cc]himp|plugin' app/Config/Events.php || true
    echo '=== Named file outline ==='
    ast-grep outline app/Config/Events.php --items all --view expanded || true
    echo '=== Named file contents ==='
    cat -n app/Config/Events.php || true

    Length of output: 26826


    Script executed:

    #!/bin/bash
    set -u
    repo='opensourcepos/opensourcepos'
    ref='e3e405605972ab20220ffdea6c51c5792a68ced2'
    dir="$(mktemp -d)"
    echo '=== Plugin files at PR head ==='
    gh api "repos/$repo/git/trees/$ref?recursive=1" --jq '.tree[] | select(.path | startswith("app/Plugins/") or startswith("app/Libraries/Plugins/")) | .path'
    echo '=== Download specific PR-head files ==='
    for path in \
      app/Plugins/README.md \
      app/Config/Events.php \
      app/Controllers/Items.php \
      app/Controllers/Plugins.php \
      app/Libraries/Plugins/PluginInterface.php \
      app/Libraries/Plugins/BasePlugin.php \
      app/Libraries/Plugins/PluginManager.php \
      app/Models/PluginConfig.php
    do
      mkdir -p "$dir/$(dirname "$path")"
      if gh api -H 'Accept: application/vnd.github.raw+json' "repos/$repo/contents/$path?ref=$ref" > "$dir/$path"; then
        echo "Downloaded $path"
      else
        echo "FAILED $path"
      fi
    done
    echo '=== PR-head structure ==='
    for path in app/Config/Events.php app/Controllers/Items.php app/Controllers/Plugins.php app/Libraries/Plugins/PluginInterface.php app/Libraries/Plugins/BasePlugin.php app/Libraries/Plugins/PluginManager.php app/Models/PluginConfig.php; do
      echo "--- $path ---"
      ast-grep outline "$dir/$path" --items all --view expanded || true
    done
    echo '=== PR-head documentation ==='
    cat -n "$dir/app/Plugins/README.md"
    echo '=== PR-head relevant implementations and call sites ==='
    for path in app/Config/Events.php app/Controllers/Items.php app/Controllers/Plugins.php app/Libraries/Plugins/PluginInterface.php app/Libraries/Plugins/BasePlugin.php app/Libraries/Plugins/PluginManager.php app/Models/PluginConfig.php; do
      echo "--- $path ---"
      rg -n -C 5 'item_(saved|change|deleted)|Events::(on|trigger)|registerEvents|registerAllNamespaces|discover|configur|[Gg]etConfigView|[Gg]etSettings|[Ss]aveSettings|[Ss]etSetting|[Gg]etSetting|isEnabled|route|save' "$dir/$path" || true
    done

    Length of output: 115496


    Script executed:

    #!/bin/bash
    set -u
    repo='opensourcepos/opensourcepos'
    ref='e3e405605972ab20220ffdea6c51c5792a68ced2'
    dir="$(mktemp -d)"
    for path in \
      app/Plugins/MailchimpPlugin/MailchimpPlugin.php \
      app/Plugins/MailchimpPlugin/Views/config.php \
      app/Plugins/MailchimpPlugin/Config/Routes.php \
      app/Plugins/MailchimpPlugin/Controllers/MailchimpController.php \
      app/Controllers/Plugins.php \
      app/Controllers/Items.php \
      app/Config/Routes.php \
      app/Config/Services.php \
      app/Libraries/Plugins/PluginManager.php
    do
      mkdir -p "$dir/$(dirname "$path")"
      gh api -H 'Accept: application/vnd.github.raw+json' "repos/$repo/contents/$path?ref=$ref" > "$dir/$path" || echo "FAILED $path"
      echo "=== Outline: $path ==="
      ast-grep outline "$dir/$path" --items all --view expanded || true
    done
    echo '=== Mailchimp plugin event and configuration code ==='
    rg -n -C 5 'function (registerEvents|getConfigView|getConfigViewData|saveSettings|install|onCustomerSaved)|Events::on|setSetting' "$dir/app/Plugins/MailchimpPlugin/MailchimpPlugin.php"
    echo '=== Mailchimp configuration view ==='
    cat -n "$dir/app/Plugins/MailchimpPlugin/Views/config.php" | sed -n '1,200p'
    echo '=== Mailchimp routes ==='
    cat -n "$dir/app/Plugins/MailchimpPlugin/Config/Routes.php"
    echo '=== Plugin controller configuration actions ==='
    cat -n "$dir/app/Controllers/Plugins.php" | sed -n '1,20p;115,171p'
    echo '=== Item bulk update ==='
    cat -n "$dir/app/Controllers/Items.php" | sed -n '1056,1097p'
    echo '=== Route and service discovery ==='
    rg -n -C 4 'Plugin|plugin|autoRoute|setAutoRoute|discover' "$dir/app/Config/Routes.php" "$dir/app/Config/Services.php" "$dir/app/Libraries/Plugins/PluginManager.php" || true

    Length of output: 65125


    @jekkos I checked the plugin framework for @hernanmardel.

    The relevant PR is #4407. It is still open and replaces the design discussed in #4255, which is closed without a merge. The details below describe the current #4407 revision and may change before merge.

    Event listener

    Put the plugin in app/Plugins/PriceComparePlugin/, with its main class in PriceComparePlugin.php. PluginManager discovers that directory and calls registerEvents() when the plugin is enabled. Do not add a plugin-specific listener to app/Config/Events.php.

    The event is item_saved, not item_change:

    public function registerEvents(): void
    {
        \CodeIgniter\Events\Events::on('item_saved', [$this, 'onItemSaved']);
    }

    The callback receives an array of item IDs and an optional $pluginData array. It can query the item model for the fields it needs.

    item_saved fires after a successful item form save or CSV import. It does not fire in Items::postBulkUpdate() in the inspected revision. If bulk price changes must sync immediately, the framework needs an event for that path too. See the item controller.

    Settings and “Compare now”

    #4407 uses a Plugins management menu, rather than adding a section to the old Plugins config tab.

    • Implement getConfigView() and return the path to the plugin’s Views/config.php, without the .php extension. The Mailchimp plugin shows the pattern.
    • Post settings to plugins/saveConfig/<pluginId>. The controller calls saveSettings(). BasePlugin provides settings storage.
    • The management menu already has an enable/disable control. If a separate sync switch is needed, use a separate setting rather than the framework’s enabled key.
    • For “Compare now”, use a plugin controller and a POST route, following the Mailchimp route and controller example. Protect the action with authorization and CSRF checks. The README and manager comments differ on route auto-discovery, so verify route loading against the final merged framework.

    Keep the proposed explicit consent check before either an automatic sync or “Compare now” sends data. Send only the agreed barcode, item name, and final retail price of active items. Keep publication as a separate opt-in.

    The plugin README has the full structure and examples.

    You are interacting with an AI system.

  5. hernanmardel commented on Nov 11, 2026

    @hernanmardel
    Author

    Thanks for the detailed pointers! I'll wait for #4407 to be merged and then build it as a plugin following that structure.

  6. hernanmardel commented on Nov 11, 2026

    @hernanmardel
    Author

    Actually, I went ahead and built it already, following the structure in #4407: https://github.com/hernanmardel/ospos-lista-inteligente
    Self-contained in app/Plugins/ListaInteligentePlugin/, no core files touched.
    Office module page with explicit consent and a "Compare with supermarkets" button (POST, CSRF-protected).
    Optional automatic updates on item_saved, off by default.
    Only for Argentina (currency ARS or Argentine timezone); sends only barcode, name and final retail price.
    The server side is live and tested. The plugin itself is syntax-checked but not yet run on the #4407 branch, since it isn't released yet. Any early feedback is welcome, and I'll test it as soon as #4407 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions