Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Introduce a new configuration field to set the DateTime Format at least for the import/export #114

Closed
wants to merge 2 commits into from

Conversation

ulftietze
Copy link
Contributor

@ulftietze ulftietze commented Jun 22, 2018

This pull request is one step of the general problem, that the import/export is facing, when it's come from export to reimport the same file. One related issue is the #61. This PR fixes one of the reasons, that this could not work.

We ran here into the problem, that the dateformat in standart format looks like eg.
German: 12.11.18 15:42:45
US: 11/12/18 15:42:45

We can't reimport this, because of the PHP "strtotime()" function.
If you called this function with this dateformat, we ran into the issue, that this date could not resolve the "18" as year at the end. Probably PHP tried to lookup for the exact year, and this could be 1918, 2018, 2118, and so on. So this breaks everything.

Now you can set your default datetime in Stores > Configuration > General > Locale > DateTime Format.
It's saved under 'general/locale/locale_date_format'.

Fixed Issues (if relevant)

  1. Probably a small thing of Exporting and reimporting products out of the box creates massive CSV bugs #61

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)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jun 22, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Ulf Tietze seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

@dmanners
Copy link
Contributor

@ulftietze I think your git user and github user are not the same or linked. Could you please check that and get back to me on this.

/**
* @api
*/
interface GetDateTimeFormatFromConfigInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there are two issues in this class/interface:

  • It's designed as a command - thing that changes the state. However, the intent of the interface is to return a format by some scope. Usually, we use noun::verb naming for such things.
  • getDefaultDatetimeFormatPath method is an implementation details. Some implementations of GetDateTimeFormatFromConfigInterface may store the datetime formats in DB or files without any XML paths.
  • Inteface and class contain a part of namespace in the names.

Considering points above I suggest to drop the getDefaultDatetimeFormatPath method from inteface and rename interface + class + execute method to something like Magento\Framework\Stdlib\DateTime\ConfigInterface::getFormat($scopeType, $scopeCode)

@@ -37,6 +37,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
const XML_PATH_DEFAULT_COUNTRY = 'general/country/default';
const XML_PATH_DEFAULT_LOCALE = 'general/locale/code';
const XML_PATH_DEFAULT_TIMEZONE = 'general/locale/timezone';
const XML_PATH_DEFAULT_DATETIME_FORMAT = 'general/locale/locale_date_format';
Copy link
Contributor

Choose a reason for hiding this comment

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

The implemntation of interface is better place for this constant

@@ -121,6 +121,10 @@
<label>Weight Unit</label>
<source_model>Magento\Directory\Model\Config\Source\WeightUnit</source_model>
</field>
<field id="locale_date_format" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, there is a circular dependency in Store-Directory modules pair. Any dependencies between these two modules are not welcome according to the desired state.

This PR defines: interface and implementation in framework; constant and system config setting in Directory module; di configuration in Store module with dependency on Directory module.

I suggest to put everything except the interface in Directory module. Alternatively, it's possible to have both interface and class in framework, and all other things in Directory module.

magento-engcom-team added a commit that referenced this pull request Jul 12, 2018
 - Merge Pull Request magento/graphql-ce#114 from magento/graphql-ce:grqphql-mutations-74
 - Merged commits:
   1. db3f2c7
   2. eb2a5a3
@dmanners
Copy link
Contributor

Hi @ulftietze I am going to close this PR due to inactivity. If you have time and want to come back to this PR please feel free to address the issues raised in the review and reopen this PR.

Thanks

@dmanners dmanners closed this Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants