Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MyModuleModelSave;
- use MyModuleModelResourceModelSaveCollectionFactory;
- class DataProvider extends MagentoUiDataProviderAbstractDataProvider
- {
- /**
- * @param string $name
- * @param string $primaryFieldName
- * @param string $requestFieldName
- * @param CollectionFactory $contactCollectionFactory
- * @param array $meta
- * @param array $data
- */
- public function __construct(
- $name,
- $primaryFieldName,
- $requestFieldName,
- CollectionFactory $contactCollectionFactory,
- array $meta = [],
- array $data = []
- ) {
- $this->collection = $contactCollectionFactory->create();
- parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
- }
- public function getData()
- {
- if (isset($this->loadedData)) {
- return $this->loadedData;
- }
- $items = $this->collection->getItems();
- $this->loadedData = array();
- /** @var Customer $customer */
- foreach ($items as $contact) {
- // notre fieldset s'apelle "contact" d'ou ce tableau pour que magento puisse retrouver ses datas :
- $this->loadedData[$contact->getId()]['contact'] = $contact->getData();
- }
- return $this->loadedData;
- }
- }
- <?php
- namespace MyModuleModelResourceModelSave;
- use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
- class Collection extends AbstractCollection
- {
- public function _construct()
- {
- $this->_init('MyModuleModelSave', 'MyModuleModelResourceModelSave');
- }
- }
- public function _initSelect()
- {
- parent::_initSelect();
- $this->getSelect()->joinLeft(
- ['secondTable' => $this->getTable('SECOND_TABLE_NAME')],
- 'main_table.COULMN_NAME_TO_JOIN_TABLE1 = secondTable.COULMN_NAME_TO_JOIN_TABLE2',
- ['COLUMN_U_WANT_TO_ADD'=>'COLUMN_NAME_OF_NEW_COLUMN']
- );
- $this->addFilterToMap('COLUMN_U_WANT_TO_ADD', 'secondTable.COLUMN_NAME_OF_NEW_COLUMN');
- }
- use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
- class Collection extends AbstractCollection
- {
- protected $_idFieldName = 'entity_id';
- /**
- * Collection constructor
- *
- *
- * @param EntityFactoryInterface $entityFactory
- * @param LoggerInterface $logger
- * @param FetchStrategyInterface $fetchStrategy
- * @param ManagerInterface $eventManager
- * @param StoreManagerInterface $storeManager
- * @param AdapterInterface $connection
- * @param AbstractDb $resource
- */
- public function __construct(
- MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory,
- PsrLogLoggerInterface $logger,
- MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy,
- MagentoFrameworkEventManagerInterface $eventManager,
- MagentoStoreModelStoreManagerInterface $storeManager,
- MagentoFrameworkDBAdapterAdapterInterface $connection = null,
- MagentoFrameworkModelResourceModelDbAbstractDb $resource = null
- ) {
- $this->_init('MyModuleModelSave', 'MyModuleModelResourceModelSave');
- $this->storeManager = $storeManager;
- parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
- }
- /**
- *
- * Filtering Data By Query on the Basis of Filtering Criteria
- *
- *
- */
- protected function _initSelect()
- {
- parent::_initSelect();
- $this->getSelect()->where('main_table.reserved_order_id NOT IN (SELECT sales_order.increment_id FROM sales_order) ');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement