Open
Description
This issue is automatically created based on existing pull request: #39123: Use static const in Magento\Customer\Model\Address\Config
Description (*)
This PR adds the possibility to create a new configuration from a custom path and create a class that extends from Magento\Customer\Model\Address\Config
without having to duplicate the function Magento\Customer\Model\Address\Config::getFormats()
use Magento\Customer\Model\Address\Config;
class ClickAndCollectConfig extends Config
{
public const XML_PATH_ADDRESS_TEMPLATE = 'click_and_collect/address_templates/';
}
Workaround
Today, the only solution to come to do is to duplicate the getFormats
function ...
use Magento\Customer\Model\Address\Config;
class ClickAndCollectConfig extends Config
{
public const XML_PATH_ADDRESS_TEMPLATE = 'click_and_collect/address_templates/';
/**
* @inheritDoc
*/
public function getFormats(): ?array
{
$store = $this->getStore();
$storeId = $store->getId();
if (!isset($this->_types[$storeId])) {
$this->_types[$storeId] = [];
foreach ($this->get() as $typeCode => $typeConfig) {
$path = sprintf('%s%s', self::XML_PATH_ADDRESS_TEMPLATE, $typeCode);
$type = new DataObject();
if (isset($typeConfig['escapeHtml'])) {
$escapeHtml = $typeConfig['escapeHtml'] == 'true' || $typeConfig['escapeHtml'] == '1';
} else {
$escapeHtml = false;
}
$format = $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
$type->setData('code', $typeCode)
->setData('title', (string)$typeConfig['title'])
->setData('default_format', $format)
->setData('escape_html', $escapeHtml);
$renderer = isset($typeConfig['renderer']) ? (string)$typeConfig['renderer'] : null;
if (!$renderer) {
$renderer = self::DEFAULT_ADDRESS_RENDERER;
}
// @phpstan-ignore-next-line
$type->setRenderer($this->_addressHelper->getRenderer($renderer)->setType($type));
$this->_types[$storeId][] = $type;
}
}
return $this->_types[$storeId];
}
}
Related Pull Requests
None
Fixed Issues (if relevant)
None
Manual testing scenarios (*)
- Create new class extend
Magento\Customer\Model\Address\Config
- Setup
XML_PATH_ADDRESS_TEMPLATE
with custom value
Contribution checklist (*)
- Pull request has a meaningful description of its purposeAll commits are accompanied by meaningful commit messagesAll new or changed code is covered with unit/integration tests (if applicable)README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an updateAll automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
Activity
m2-assistant commentedon Sep 4, 2024
Hi @engcom-November. 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: 👇
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
Issue: Confirmed
once verification is complete.engcom-November commentedon Sep 4, 2024
Hello @dimitriBouteille,
Thank you for the report and collaboration!
Going through the issue this can be considered as a bug, hence confirming this.
github-jira-sync-bot commentedon Sep 4, 2024
✅ Jira issue https://jira.corp.adobe.com/browse/AC-12906 is successfully created for this GitHub issue.
m2-assistant commentedon Sep 4, 2024
✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.