Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#518 Simplest “By Priority” Algorithm implementation #560

Merged
merged 26 commits into from
Mar 1, 2018

Conversation

roma-glushko
Copy link
Member

@roma-glushko roma-glushko commented Feb 17, 2018

Implement shipping selection algorithm by source priority.

Fixed Issues

  1. Simplest “By Priority” Algorithm implementation #518: Simplest “By Priority” Algorithm implementation

To Do

  • Refactor DefaultShippingAlgorithm to PriorityShippingAlgorithm
  • Render warning message on the order view page in the appropriate table
  • Adjust integration tests
  • UAT

*/
private function isZero(float $floatNumber): bool
{
return $floatNumber < 0.0001;
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a pity that Constant has been added just in PHP 7.2

PHP_FLOAT_EPSILON (float)
Smallest representable positive number x, so that x + 1.0 != 1.0. Available as of PHP 7.2.0.

Please, make the precision a bit less, like 0.0000001

@p-bystritsky p-bystritsky self-assigned this Feb 22, 2018
@p-bystritsky p-bystritsky removed the WIP label Feb 26, 2018
*
* @return SourceItemInterface
*/
private function getStockItemBySku(string $stockCode, string $sku): SourceItemInterface
Copy link

Choose a reason for hiding this comment

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

Description talks about one behavior
Method name talks about another behavior
Implementation return the other

Also, you can reuse \Magento\Inventory\Model\SourceItem\Command\GetSourceItemsBySkuInterface

* {@inheritdoc}
* This shipping algorithm just iterates over all the sources one by one in priority order
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Copy link

Choose a reason for hiding this comment

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

We should not add suppressing in new code (only in special cases)
We can split this class on a few, first is loading data, second is perform algorithm

@naydav naydav merged commit f4ab977 into develop Mar 1, 2018
@maghamed maghamed deleted the 518-priority-adjustments-simple-selection-algorithm branch February 5, 2019 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants