- 
                Notifications
    
You must be signed in to change notification settings  - Fork 254
 
Introduce API interfaces for Assigning Stocks to Sales channels #151 #150
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
Conversation
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | 
There was a problem hiding this comment.
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; | ||
| 
               | 
          ||
| /**#@+ | 
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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} | 
There was a problem hiding this comment.
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(); | ||
| 
               | 
          
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove new line pls
…es channels to stocks
There was a problem hiding this 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 | ||
| */ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header block is wrong
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | ||
| */ | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | ||
| } | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. | 
There was a problem hiding this comment.
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[]
There was a problem hiding this comment.
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; | ||
| 
               | 
          ||
| /** | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" /> | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
… into msi-inventory-mapping
… into msi-inventory-mapping
… into msi-inventory-mapping
… Fixed wrong foreign key in sales channels link table.
… Fixed bug in plugin.
… Created first test case for sales channels links.
… Completed web api tests.
… Fixed issues found by travis ci.
… into msi-inventory-mapping
- declare Magento_InventorySales sequences
… into msi-inventory-mapping
… Removed wrong fix for issues found by travis ci.
-- slight refactoring
L3_PR_21-10-10
Description
Created additional table to store stock channel items for msi inventory mapping.
Related Issues
#151
Manual testing scenarios
Contribution checklist