conneqt/module-sap-my-account
最新稳定版本:2.4.0
Composer 安装命令:
composer require conneqt/module-sap-my-account
包简介
This module lets you directly display SAP data into your Magento shop
README 文档
README
What this module does
Conneqt_SapMyAccount adds SAP-driven pages to the Magento 2 customer account area.
Instead of showing only Magento-native account data, this module can expose customer information that lives in SAP, such as:
- account details
- addresses
- contact / management users
- order history
- invoice history
- quotations
- deliveries
- return requests
- backorders
- equipment card related pages
The module does this by adding customer account routes under my-account/*, fetching data from SAP through the conneqt/module-sap-base integration, and rendering the results with Magento blocks, templates, and controllers.
In short: how it works
At a high level the flow is:
- A customer opens a page in the account area.
- The module decides, based on configuration, whether Magento should use the SAP page or the default Magento page.
- A controller loads a Magento page result.
- A block requests data from SAP through one of the API helper classes.
- Shared base blocks format, filter, paginate, and map the SAP data for the frontend.
- URL translation logic can expose friendly or translated storefront paths while still resolving to the internal
my-account/*routes.
Most list/detail pages in this module follow that same pattern.
Main concepts
1. Feature switches in configuration
Almost every feature can be enabled or disabled separately through store configuration.
Examples:
- dashboard
- address book
- management contacts
- orders
- invoices
- returns
- quotations
- deliveries
- backorders
- equipment cards
These values are read centrally by Helper/ScopeConfigHelper.php.
2. Customer to SAP mapping
SAP data is loaded for the currently logged-in Magento customer.
The key customer attribute is card_code (CardCode in the admin UI / customer data). This value must match the SAP business partner code for the customer. Some queries can also use internal contact-person filtering when the customer has the related custom attributes available.
Important note:
- the SAP base module must be configured with working credentials first
- the customer must have the correct
CardCode - the dashboard/account data assumes the Magento customer can be matched to SAP customer data
3. Shared list and detail rendering
The module has reusable base blocks for SAP-backed pages:
Block/Base/Lister.phpbuilds list filters, sorting, pagination, and API select fieldsBlock/Base/Details.phploads one SAP document and prepares detail dataBlock/Base/MyAccountData.phpformats values, dates, prices, and configured field mappingsBlock/Base/MyAccountBase.phphandles common URL building and error handling
Because of these base classes, feature-specific pages such as orders, invoices, quotations, and deliveries usually only need small child classes plus layout/templates.
4. URL translation and custom routing
The module front name is my-account, but it can also translate storefront URLs using configuration.
Controller/Router.phptranslates friendly storefront paths back to the internal module routeHelper/UrlTranslationHelper.phpconverts between internal and translated URLsBlock/Navigation/UrlNavigation.phpuses that translation logic when rendering account navigation links
This makes it possible to keep internal routes stable while showing custom storefront paths.
5. Checkout address restrictions
When SAP account/address functionality is enabled, the module also adjusts the checkout address UI.
Block/Checkout/LayoutProcessor.php replaces parts of the checkout JS layout so billing and shipping address lists can be filtered by SAP address type, and so the frontend can respect whether creating new addresses is allowed.
Important files and what they do
Configuration
etc/config.xml
Provides default configuration values for all feature areas, list columns, detail columns, mappings, status options, and URL settings.etc/adminhtml/system.xml
Defines the admin configuration fields shown in Magento.Helper/ScopeConfigHelper.php
Main read-access layer for this module's configuration. Most controllers and blocks use this helper instead of reading raw config paths directly.
Routing and navigation
etc/frontend/routes.xml
Registers the module under themy-accountfront name.etc/frontend/di.xml
Registers the custom router and checkout layout processor, and configures the custom frontend error message renderer for RMA errors.Controller/Router.php
Rewrites translated storefront URLs back to the original internal route so Magento can dispatch them.Plugin/DashboardRedirect.php
Redirects the standard Magento customer dashboard to the SAP dashboard when that feature is enabled.view/frontend/layout/customer_account.xml
Replaces or adds customer account navigation links so account menu items point to SAP pages when enabled.Block/Navigation/UrlNavigation.php
Renders navigation links that respect config switches and translated URLs.
SAP API layer
Helper/Api/ApiBase.php
Shared SAP API base class. It resolves the current customer and exposes helpers such asgetCardCode().Helper/Api/ApiData.php
Shared document-query layer for SAP lists and details. It builds OData filters, sorting, pagination, and date limits.Helper/Api/ApiAccount.php
Loads and updates SAP business partner account data.Helper/Api/ApiOrder.php
Small feature-specific API class for order data; child API classes for invoices, returns, deliveries, and quotations follow the same pattern.
Shared storefront blocks
Block/Base/MyAccountBase.php
Shared error handling and translated URL generation.Block/Base/MyAccountData.php
Shared value formatting and mapping layer.Block/Base/Lister.php
Shared grid/list behavior for SAP history pages.Block/Base/Details.php
Shared detail-page behavior for SAP documents.Block/Base/Filter.php
Builds the filter UI for list pages using configuration-defined fields.
Representative controllers
Controller/Order/History.php
Example of a feature controller that checks config, loads a Magento page, and renders a SAP-backed history page.Controller/Management/Save.php
Updates or creates SAP contact employees for account management users.Controller/Rma/GuestCreate.php
Creates a guest return request and redirects to the guest return details page.Controller/Download/Pdf.php
Downloads document attachments from SAP-backed records.
Returns and guest return creation
Helper/RmaCreateData.php
Builds the payload sent to SAP when creating a return request. It validates request data, selects return lines, and recalculates totals.Block/Rma/*andController/Rma/*
Handle the return overview, detail pages, request form, guest search flow, and downloads.
Repair requests / equipment-related storage
etc/db_schema.xml
Creates theconneqt_repair_requeststable used for stored repair request data.Model/RepairRequest.phpandResourceModel/*
Provide the Magento model/resource layer for that table.
Supported feature areas
This module is structured around separate feature families. Depending on configuration, a shop can enable only the parts it needs.
- Dashboard: SAP-backed account overview and profile editing
- Address: SAP-backed customer address overview, create, and edit
- Management: manage contact employees / account contacts
- Orders: SAP order history and detail pages
- Invoices: SAP invoice history and detail pages
- Returns: return overview, request flow, guest search, and PDF/download support
- Quotations: SAP quotation history and details
- Deliveries: SAP delivery history and details
- Backorders: custom SAP query based backorder overview
- Equipment Cards / Repairs: equipment pages and repair request functionality
Setup notes
Required dependency
This module depends on conneqt/module-sap-base.
Before using this module, make sure the SAP base module is configured with valid API credentials in Magento admin.
Customer requirements
For a customer to see SAP data:
- the customer must be able to authenticate normally in Magento
- the customer record must contain the correct
CardCode - that
CardCodemust match the SAP business partner code
Admin configuration behavior
The most important configuration switches behave roughly as follows:
- Use SAP account: redirects account/dashboard navigation to the SAP dashboard pages
- Use SAP address: redirects the address book to SAP-backed pages and also affects SAP dashboard address output
- Allow creating new addresses: enables the create-address option in the SAP address area and checkout integration
- Use SAP order history: sends order history navigation to the SAP order pages
- Use SAP return request: adds the SAP return pages to the account navigation
- Use SAP invoice: adds invoice history to the account navigation
Backorders setup
Backorders are not loaded from a standard SAP endpoint in this module. A custom SQL query must exist in SAP.
Example request:
- Type:
POST - URL:
{{base_url}}SQLQueries - Body:
{
"SqlCode": "GetBackorders",
"SqlName": "GetOrderInfoForCustomer",
"SqlText": "SELECT ORDR.DocNum, ORDR.DocEntry, ORDR.DocDate,ORDR.DocDueDate,RDR1.ItemCode,RDR1.Dscription as Description,RDR1.Price, RDR1.OpenQty, RDR1.Quantity FROM ORDR ORDR inner join RDR1 RDR1 on ORDR.DocEntry = RDR1.DocEntry inner join OCRD OCRD on ORDR.CardCode = OCRD.CardCode WHERE ORDR.DocStatus <> 'C' and RDR1.LineStatus <> 'C' and RDR1.OpenQty <> 0 and ORDR.CardCode = :CardCode"
}
Quick mental model for developers
If you are new to this module, the easiest way to understand it is:
- Start with
view/frontend/layout/customer_account.xmlto see which account links are replaced or added. - Check
etc/frontend/routes.xmlandController/Router.phpto understand request routing. - Open a feature controller such as
Controller/Order/History.php. - Follow the feature block into
Block/Base/Lister.phporBlock/Base/Details.php. - Follow the API call into
Helper/Api/ApiData.phpand the feature-specificHelper/Api/*class. - Use
Helper/ScopeConfigHelper.phpto find the related configuration.
That path gives a good picture of how nearly all storefront features in this module are built.
统计信息
- 总下载量: 7.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-10-24