Skip to content

Conversation

@belinda-tschampel
Copy link
Contributor

@belinda-tschampel belinda-tschampel commented Oct 25, 2017

Description

Created additional table to store stock channel items for msi inventory mapping.

Related Issues

#151

Manual testing scenarios

  1. Install InventorySales and InventorySalesApi Module and check if 'inventory_stock_sales_channel' table was created.

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)

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Please use declare(strict_types=1); in all Files

*/
use PredefinedId;

/**#@+
Copy link
Member

Choose a reason for hiding this comment

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

PHP documentation toll drop support for /**#@+ pls don't use as anymore

/**
* Resource Collection of Source Items entity
*
* @api
Copy link
Member

Choose a reason for hiding this comment

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

don't use @api in a implemented class @api only for interfaces

}

/**
* {@inheritdoc}
Copy link
Member

Choose a reason for hiding this comment

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

use pls @inheritdoc without {} - {@inheritdoc} is only for DocBlocks if you must write a more specific description

public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();

Copy link
Member

Choose a reason for hiding this comment

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

remove new line pls

@belinda-tschampel belinda-tschampel changed the title Store stock channel table for msi inventory mapping Introduce API interfaces for Assigning Stocks to Sales channels #151 Oct 26, 2017
Copy link
Contributor

@maghamed maghamed left a comment

Choose a reason for hiding this comment

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

Two more plugins:
afterSave and afterGetList
should be provided

and code covered with Integration test

* User: tschampelb
* Date: 26.10.17
* Time: 11:53
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Header block is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


use Magento\InventorySales\Model\ResourceModel\SalesChannelsResolver;

class GetSalesChannelByStock implements GetSalesChannelsByStockInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

Name should be plural GetSalesChannelsByStock the same as interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

class GetSalesChannelByStock implements GetSalesChannelsByStockInterface
{
/** @var SalesChannelsResolver */
protected $salesChannelsResolver;
Copy link
Contributor

Choose a reason for hiding this comment

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

all properties in the new code should be private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

protected $salesChannelsResolver;


public function __construct(
Copy link
Contributor

Choose a reason for hiding this comment

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

Annotation block should be added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

$this->salesChannelsResolver = $salesChannelsResolver;
}

public function get(int $stockId) : array
Copy link
Contributor

Choose a reason for hiding this comment

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

PHP DocBlock annotation should be added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

use Magento\InventorySalesApi\Api\Data\StockChannelSearchResultsInterface;

/**
* In Magento 2 Repository considered as an implementation of Facade pattern which provides a simplified interface
Copy link
Contributor

Choose a reason for hiding this comment

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

This description is copy pasted from repository , please provide correct one

<plugin name="stockChannelData" type="Magento\InventorySales\Plugin\Inventory\StockRepository\SalesChannelDataAfterGetPlugin" />
</type>

</config> No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

add an extra line at the end

Copy link
Contributor

Choose a reason for hiding this comment

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

done

* User: tschampelb
* Date: 26.10.17
* Time: 12:08
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Doc Block should be fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* The resource model responsible for retrieving StockItem Quantity.
* Used by Service Contracts that are agnostic to the Data Access Layer.
*/
class SalesChannelsResolver
Copy link
Contributor

Choose a reason for hiding this comment

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

Better change the name to SalesChannelProvide because this class provides SalesChannels by given stock id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

$salesChannel->setType($channelItem['type']);
$salesChannel->setCode($channelItem['code']);
$retArray[] = $salesChannel;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this foreach logic could be moved to the model upper level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @param string $code
* @return void
*/
public function setCode(string $code);
Copy link
Contributor

Choose a reason for hiding this comment

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

get/setExtension attributes methods should be introduced to this interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

interface GetSalesChannelsByStockInterface
{
/**
* Get Sales Channel data by given stockId.
Copy link

Choose a reason for hiding this comment

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

Provide more clear description
We return not some "data" but SalesChannels object

@return SalesChannels[]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


namespace Magento\InventorySales\Model;

/**
Copy link

Choose a reason for hiding this comment

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

Create proper dockblock, this is copy paste from repository

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/**
* Provides possibility of saving entity with predefined/pre-generated id
*/
use PredefinedId;
Copy link

Choose a reason for hiding this comment

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

Looks like for this object we do not need predefined id functionality
And generally looks like we do not need ResourceModel for this entity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}


public function addFilterByStockId(int $stockId)
Copy link

Choose a reason for hiding this comment

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

Why do we need these "filtering" methods in this collection?

Generally, looks like we do need this class because we already have logic of resolving in StockResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/** @var StockExtension $extensionAttributes */
$extensionAttributes = $result->getExtensionAttributes();
$salesChannelSearchResults = $this->getSalesChannelByStock->get((int)$result->getStockId());
$extensionAttributes->setData('sales_channels', $salesChannelSearchResults);
Copy link

Choose a reason for hiding this comment

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

Do not use setData method, you could use method which was described extension_attributes.xml

Copy link
Contributor

Choose a reason for hiding this comment

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

done

<preference for="Magento\InventorySales\Model\GetSalesChannelsByStockInterface" type="Magento\InventorySales\Model\GetSalesChannelByStock"/>

<type name="Magento\InventoryApi\Api\StockRepositoryInterface">
<plugin name="stockChannelData" type="Magento\InventorySales\Plugin\Inventory\StockRepository\SalesChannelDataAfterGetPlugin" />
Copy link

Choose a reason for hiding this comment

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

Pls use underscore for plugin name instead of camelcase

Copy link
Contributor

Choose a reason for hiding this comment

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

done

belinda-tschampel and others added 21 commits October 28, 2017 17:40
… Fixed wrong foreign key in sales channels link table.
… Created first test case for sales channels links.
- declare Magento_InventorySales sequences
… Removed wrong fix for issues found by travis ci.
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.

6 participants