├── Controller ├── Adminhtml │ ├── shipment │ │ ├── NewAction.php │ │ └── Save.php │ └── Order │ │ ├── Index.php │ │ └── View.php └── Account │ ├── Create.php │ └── save.php ├── Shipping └── Block │ └── Adminhtml │ ├── Create │ └── Items.php │ └── Create.php ├── Sales ├── Ui │ └── Component │ │ └── Listing │ │ └── Column │ │ └── ViewAction.php ├── Block │ └── Adminhtml │ │ └── Order │ │ ├── View.php │ │ └── View │ │ └── Items.php └── Model │ └── ResourceModel │ └── Order │ └── Grid │ └── Collection.php ├── view ├── adminhtml │ ├── templates │ │ ├── shipment │ │ │ └── create │ │ │ │ └── items.phtml │ │ └── order │ │ │ └── view │ │ │ └── items.phtml │ ├── layout │ │ ├── seller_order_index.xml │ │ ├── adminhtml_user_edit.xml │ │ ├── seller_shipment_new.xml │ │ └── seller_order_view.xml │ └── ui_component │ │ └── seller_order_listing.xml └── frontend │ ├── layout │ └── multicart_account_create.xml │ └── templates │ └── seller │ └── account │ └── create.phtml ├── registration.php ├── Block ├── Seller │ └── Account │ │ └── Create.php └── Adminhtml │ └── User │ └── Edit │ └── Tab │ └── Content.php ├── etc ├── frontend │ └── routes.xml ├── adminhtml │ ├── routes.xml │ ├── menu.xml │ ├── di.xml │ ├── events.xml │ └── system.xml ├── module.xml ├── di.xml └── acl.xml ├── Model ├── Config │ └── Source │ │ └── Role.php ├── ResourceModel │ ├── Profile.php │ └── Profile │ │ └── Collection.php └── Profile.php ├── Event ├── User │ └── Save.php ├── System │ └── Account │ │ └── Save.php └── Catalog │ └── Controller │ └── Adminhtml │ └── Product │ └── Save.php ├── Catalog └── Collection.php ├── Api └── Data │ └── ProfileInterface.php ├── README.md ├── Setup ├── InstallData.php └── InstallSchema.php └── Plugin └── Block └── Adminhtml └── System └── Account └── Edit └── Form.php /Controller/Adminhtml/shipment/NewAction.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmansorkar/MultiCart/HEAD/Controller/Adminhtml/shipment/NewAction.php -------------------------------------------------------------------------------- /Shipping/Block/Adminhtml/Create/Items.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmansorkar/MultiCart/HEAD/Shipping/Block/Adminhtml/Create/Items.php -------------------------------------------------------------------------------- /Sales/Ui/Component/Listing/Column/ViewAction.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmansorkar/MultiCart/HEAD/Sales/Ui/Component/Listing/Column/ViewAction.php -------------------------------------------------------------------------------- /view/adminhtml/templates/shipment/create/items.phtml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmansorkar/MultiCart/HEAD/view/adminhtml/templates/shipment/create/items.phtml -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | _urlBuilder->getUrl("seller/account/save"); 7 | } 8 | } -------------------------------------------------------------------------------- /etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Shipping/Block/Adminhtml/Create.php: -------------------------------------------------------------------------------- 1 | getUrl( 16 | 'seller/order' 17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /view/frontend/layout/multicart_account_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Controller/Account/Create.php: -------------------------------------------------------------------------------- 1 | resultPageFactory=$resultPageFactory; 11 | parent::__construct($context); 12 | } 13 | 14 | public function execute(){ 15 | return $this->resultPageFactory->create(); 16 | } 17 | } -------------------------------------------------------------------------------- /view/adminhtml/layout/seller_order_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sales/Block/Adminhtml/Order/View.php: -------------------------------------------------------------------------------- 1 | getUrl('seller/shipment/new'); 9 | } 10 | 11 | public function getBackUrl() 12 | { 13 | 14 | return $this->getUrl('seller/*/'); 15 | } 16 | 17 | protected function _isAllowedAction($resourceId) 18 | { 19 | if($resourceId=='Magento_Sales::ship'){ 20 | return true; 21 | } 22 | return $this->_authorization->isAllowed($resourceId); 23 | } 24 | } -------------------------------------------------------------------------------- /etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OsmanSorkar\MultiCart\Catalog\Collection 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Model/Config/Source/Role.php: -------------------------------------------------------------------------------- 1 | roleFactory=$roleFactory; 11 | } 12 | /** 13 | * @return array 14 | */ 15 | public function toOptionArray() 16 | { 17 | $array=[]; 18 | $roles=$this->roleFactory->create()->getCollection()->addFieldToFilter("role_type","G"); 19 | foreach ($roles as $role){ 20 | $array[]=['value' => $role->getId(), 'label' => __($role->getRoleName())]; 21 | } 22 | return $array; 23 | } 24 | } -------------------------------------------------------------------------------- /Event/User/Save.php: -------------------------------------------------------------------------------- 1 | _request = $request; 13 | $this->_sellerProfile = $sellerProfile; 14 | } 15 | 16 | public function execute(\Magento\Framework\Event\Observer $observer) { 17 | $user = $observer->getEvent()->getObject(); 18 | $profile=$this->_sellerProfile->loadProfileById($user->getId()); 19 | $id = $profile->getId(); 20 | $profile->setData($user->getData()); 21 | $profile->setId($id); 22 | $profile->save(); 23 | } 24 | } -------------------------------------------------------------------------------- /etc/adminhtml/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Event/System/Account/Save.php: -------------------------------------------------------------------------------- 1 | _authSession = $authSession; 13 | $this->_sellerProfile = $sellerProfile; 14 | } 15 | 16 | public function execute(\Magento\Framework\Event\Observer $observer) { 17 | 18 | $request= $observer->getRequest(); 19 | $userId = $this->_authSession->getUser()->getId(); 20 | $profile = $this->_sellerProfile->loadProfileById($userId); 21 | $profile->setImage($request->getParam("image")); 22 | $profile->setShopName($request->getParam("shop_name")); 23 | $profile->save(); 24 | } 25 | } -------------------------------------------------------------------------------- /Model/ResourceModel/Profile.php: -------------------------------------------------------------------------------- 1 | _init('multicart_profile', 'entity_id'); 17 | } 18 | /** 19 | * Load data by specified username 20 | * 21 | * @param string $username 22 | * @return array 23 | */ 24 | public function loadProfileById($id) 25 | { 26 | $connection = $this->getConnection(); 27 | 28 | $select = $connection->select()->from($this->getMainTable())->where('user_id=:id'); 29 | 30 | $binds = ['id' => $id]; 31 | 32 | return $connection->fetchRow($select, $binds); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /Model/ResourceModel/Profile/Collection.php: -------------------------------------------------------------------------------- 1 | _init('OsmanSorkar\MultiCart\Model\Profile', 'OsmanSorkar\MultiCart\Model\ResourceModel\Profile'); 25 | } 26 | 27 | public function getAllSellerId(){ 28 | if(empty($this->_allSellerId)){ 29 | $this->_allSellerId=array_column($this->getData(),"user_id"); 30 | } 31 | return $this->_allSellerId; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Catalog/Collection.php: -------------------------------------------------------------------------------- 1 | _objectManager->get("\Magento\Backend\Model\Auth\Session")->getUser(); 8 | $roleId = $userModel->getRole()->getId(); 9 | if($roleId == $this->getVendorRule()){ 10 | $collectionFactory->addFieldToFilter("product_user_id",$userModel->getId()); 11 | } 12 | return $collectionFactory; 13 | } 14 | 15 | protected function getVendorRule(){ 16 | $scopeConfig=$this->_objectManager->get("\Magento\Framework\App\Config\ScopeConfigInterface"); 17 | 18 | return $scopeConfig->getValue( 19 | 'multicart_section/general/vendor_role', 20 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE 21 | ); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /view/adminhtml/layout/adminhtml_user_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | user_section 14 | osmansorkar_attribute_content 15 | main_section 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Event/Catalog/Controller/Adminhtml/Product/Save.php: -------------------------------------------------------------------------------- 1 | authSession=$authSession; 10 | } 11 | /** 12 | * @override 13 | * @see ObserverInterface::execute() 14 | * @used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod() 15 | * @see \Magento\Framework\App\Action\Action::dispatch() 16 | * https://github.com/magento/magento2/blob/dd47569249206b217e0a9f9a9371e73fd7622724/lib/internal/Magento/Framework/App/Action/Action.php#L91-L92 17 | $eventParameters = ['controller_action' => $this, 'request' => $request]; 18 | $this->_eventManager->dispatch('controller_action_predispatch', $eventParameters) 19 | * @param \Magento\Framework\Event\Observer $observer 20 | * @return void 21 | */ 22 | public function execute(\Magento\Framework\Event\Observer $observer) { 23 | $product = $observer->getEvent()->getProduct(); 24 | if($product->isObjectNew()){ 25 | $product->setData("product_user_id",$this->authSession->getUser()->getId()); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OsmanSorkar\MultiCart\Catalog\Collection 6 | 7 | 8 | 9 | 10 | 11 | sales_order_grid 12 | Magento\Sales\Model\ResourceModel\Order 13 | 14 | 15 | 16 | 17 | 18 | 19 | \OsmanSorkar\MultiCart\Sales\Model\ResourceModel\Order\Grid\Collection 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /etc/adminhtml/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | multicart_tab 15 | OsmanSorkar_MultiCart::seller 16 | 17 | 18 | 19 | 20 | OsmanSorkar\MultiCart\Model\Config\Source\Role 21 | 22 | 23 |
24 |
25 |
-------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Api/Data/ProfileInterface.php: -------------------------------------------------------------------------------- 1 | resultPageFactory=$resultPageFactory; 26 | parent::__construct($context); 27 | 28 | } 29 | public function execute(){ 30 | 31 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ 32 | $resultPage = $this->resultPageFactory->create(); 33 | $resultPage->setActiveMenu('OsmanSorkar_Blog::post'); 34 | $resultPage->addBreadcrumb(__('Blog Posts'), __('Blog Posts')); 35 | $resultPage->addBreadcrumb(__('Manage Blog Posts'), __('Manage Blog Posts')); 36 | $resultPage->getConfig()->getTitle()->prepend(__('Blog Posts')); 37 | 38 | return $resultPage; 39 | } 40 | 41 | /** 42 | * @return bool 43 | */ 44 | public function _isAllowed(){ 45 | return $this->_authorization->isAllowed("OsmanSorkar_MultiCart::order"); 46 | } 47 | } -------------------------------------------------------------------------------- /Controller/Adminhtml/Order/View.php: -------------------------------------------------------------------------------- 1 | _initOrder(); 19 | $resultRedirect = $this->resultRedirectFactory->create(); 20 | 21 | if ($order) { 22 | try { 23 | $resultPage = $this->_initAction(); 24 | $resultPage->getConfig()->getTitle()->prepend(__('Orders')); 25 | } catch (\Exception $e) { 26 | $this->logger->critical($e); 27 | $this->messageManager->addError(__('Exception occurred during order load')); 28 | $resultRedirect->setPath('seller/order/index'); 29 | return $resultRedirect; 30 | } 31 | //$resultPage->getLayout()->createBlock('\OsmanSorkar\MultiCart\Block\Adminhtml\Order'); 32 | $resultPage->getConfig()->getTitle()->prepend(sprintf("#%s", $order->getIncrementId())); 33 | return $resultPage; 34 | } 35 | $resultRedirect->setPath('seller/*/'); 36 | return $resultRedirect; 37 | } 38 | 39 | /** 40 | * @return bool 41 | */ 42 | protected function _isAllowed() 43 | { 44 | return $this->_authorization->isAllowed('OsmanSorkar_MultiCart::view'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sales/Model/ResourceModel/Order/Grid/Collection.php: -------------------------------------------------------------------------------- 1 | orderFactory=$orderFactory; 29 | $this->profileFactory=$profileFactory; 30 | $this->productFactory=$productFactory; 31 | $this->adminSession=$adminSession; 32 | $this->removeOtherSellerOrder(); 33 | } 34 | 35 | public function getTotalCount(){ 36 | return count($this); 37 | } 38 | 39 | protected function removeOtherSellerOrder(){ 40 | $allProductId=$this->profileFactory->create()->loadProfileById($this->adminSession->getUser()->getId())->getAllProductId($this->productFactory); 41 | foreach ($this as $key=>$order){ 42 | $productsId=array(); 43 | $products=$this->orderFactory->create()->load($order->getId())->getAllItems(); 44 | foreach ($products as $product){ 45 | $productsId[]=$product->getProductId(); 46 | } 47 | if(count(array_intersect($allProductId,$productsId))==0){ 48 | $this->removeItemByKey($key); 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /view/adminhtml/templates/order/view/items.phtml: -------------------------------------------------------------------------------- 1 | 10 | getOrder() ?> 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | getItemsCollection();?> 28 | 29 | getProductId(),$block->getUserAllProductId())){ 30 | continue; 31 | } ?> 32 | getParentItem()) { 33 | continue; 34 | } else { 35 | $i++; 36 | }?> 37 | 38 | getItemHtml($_item) ?> 39 | getItemExtraInfoHtml($_item) ?> 40 | 41 | 42 |
43 |
44 | -------------------------------------------------------------------------------- /Sales/Block/Adminhtml/Order/View/Items.php: -------------------------------------------------------------------------------- 1 | profileFactory=$profileFactory; 32 | $this->productFactory=$productFactory; 33 | $this->adminSession=$adminSession; 34 | } 35 | 36 | /** 37 | * Retrieve required options from parent 38 | * 39 | * @return void 40 | * @throws \Magento\Framework\Exception\LocalizedException 41 | */ 42 | protected function _beforeToHtml() 43 | { 44 | if (!$this->getParentBlock()) { 45 | throw new \Magento\Framework\Exception\LocalizedException(__('Invalid parent block for this block')); 46 | } 47 | $this->setOrder($this->getParentBlock()->getOrder()); 48 | parent::_beforeToHtml(); 49 | } 50 | 51 | /** 52 | * Retrieve order items collection 53 | * 54 | * @return Collection 55 | */ 56 | 57 | public function getItemsCollection() 58 | { 59 | return $this->getOrder()->getItemsCollection(); 60 | } 61 | public function getUserAllProductId(){ 62 | return $this->profileFactory->create()->loadProfileById($this->adminSession->getUser()->getId())->getAllProductId($this->productFactory); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Controller/Account/save.php: -------------------------------------------------------------------------------- 1 | profileFactory=$profileFactory; 18 | $this->userFactory=$userFactory; 19 | $this->urlModel=$urlFactory->create(); 20 | $this->scopeConfig=$scopeConfig; 21 | parent::__construct($context); 22 | } 23 | 24 | protected function getVendorRule(){ 25 | return $this->scopeConfig->getValue( 26 | 'multicart_section/general/vendor_role', 27 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE 28 | ); 29 | } 30 | 31 | public function execute(){ 32 | 33 | $resultRedirect =$this->resultRedirectFactory->create(); 34 | $data = $this->getRequest()->getPostValue(); 35 | /** @var $model \Magento\User\Model\User */ 36 | $model = $this->userFactory->create(); 37 | $model->setData($data); 38 | 39 | if($this->getVendorRule()==NULL && empty($this->getVendorRule())){ 40 | $model->setIsActive('0'); 41 | } 42 | else{ 43 | $model->setRoleId($this->getVendorRule()); 44 | } 45 | $profile=$this->profileFactory->create(); 46 | try{ 47 | $model=$model->save(); 48 | $profile->setAdminCommission('10'); 49 | $profile->setUserId($model->getId()); 50 | $profile->save(); 51 | $this->messageManager->addSuccessMessage("We save and create seller account"); 52 | return $resultRedirect->setPath('cms/index/index'); 53 | } catch (\Magento\Framework\Validator\Exception $e) { 54 | $messages = $e->getMessages(); 55 | $this->messageManager->addMessages($messages); 56 | $resultRedirect->setPath("*/*/create"); 57 | } 58 | catch (\Exception $e) { 59 | $this->messageManager->addException($e, __('We can\'t save the seller.')); 60 | } 61 | $resultRedirect->setPath("*/*/create"); 62 | return $resultRedirect; 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # magento2 Multi Vendor Module / MultiCart 2 | Try To create Magento 2 Multi Vendor Module- Now it is only developer version. 3 | 4 | Current Features 5 | -------- 6 | 7 | 15 | 16 | Upcoming Features 17 | -------- 18 | 19 | 25 | 26 | # Install Process 27 | 28 | 1. Install Manually 29 | --- 30 |
    31 |
  1. Create directory in app\code\OsmanSorkar\MultiCart
  2. 32 |
  3. Clone This repository on created directory
  4. 33 |
  5. Active This Module by run in terminal from Magento root directory bin/magento module:active OsmanSorkar_MultiCart
  6. 34 |
  7. run "bin/magento setup:upgrade" in terminal
  8. 35 |
  9. Have to Create a Selleter/Vendor role and Have to set from default seller/vendor role from settings
  10. 36 |
37 | 38 | 39 | Login/ Registration URl 40 | -------- 41 | **Seller Account Sign Up Url:** wwwo.domain.xx/seller/account/create/ 42 | 43 | **Seller Login :** Same as Admin login url - wwwo.domain.xx/adminxxx 44 | 45 | ## Contributing, Issues & Pull Requests 46 | 47 | Feel free to create issues to request new features or to report bugs & problems. Just please follow the template given when creating the issue. 48 | 49 | Pull requests are welcome. Unless a small tweak, It may be best to open the pull request early or create an issue for your intended change to discuss how it will fit in to the project and plan out the merge. Just because a feature request exists, or is tagged, does not mean that feature would be accepted into the core project. 50 | 51 | Pull requests should be created from the `master` branch since they will be merged back into `master` once done. 52 | 53 | ## Support Magento Version 54 | 55 | This Module last update by using Magento ver. 2.3.4 -------------------------------------------------------------------------------- /view/adminhtml/layout/seller_shipment_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Setup/InstallData.php: -------------------------------------------------------------------------------- 1 | eavSetupFactory = $eavSetupFactory; 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength) 52 | */ 53 | public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) 54 | { 55 | /** @var EavSetup $eavSetup */ 56 | $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); 57 | 58 | /** 59 | * Add attributes to the eav/attribute 60 | */ 61 | 62 | $eavSetup->addAttribute( 63 | \Magento\Catalog\Model\Product::ENTITY, 64 | 'product_user_id', 65 | [ 66 | 'type' => 'int', 67 | 'backend' => '', 68 | 'frontend' => '', 69 | 'label' => 'Product User Id', 70 | 'input' => '', 71 | 'class' => '', 72 | 'source' => '', 73 | 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, 74 | 'visible' => false, 75 | 'required' => false, 76 | 'user_defined' => false, 77 | 'default' => 0, 78 | 'searchable' => false, 79 | 'filterable' => false, 80 | 'comparable' => false, 81 | 'visible_on_front' => false, 82 | 'used_in_product_listing' => true, 83 | 'unique' => false, 84 | 'apply_to' => '' 85 | ] 86 | ); 87 | } 88 | } -------------------------------------------------------------------------------- /Setup/InstallSchema.php: -------------------------------------------------------------------------------- 1 | startSetup(); 29 | 30 | /** 31 | * Create table 'osmansorkar_blog_post' 32 | */ 33 | $table = $installer->getConnection()->newTable( 34 | $installer->getTable('multicart_profile') 35 | )->addColumn( 36 | 'entity_id', 37 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 38 | null, 39 | ['identity' => true, 'nullable' => false, 'primary' => true], 40 | 'ID' 41 | )->addColumn( 42 | 'user_id', 43 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 44 | null, 45 | ['nullable' => false], 46 | 'User ID' 47 | )->addColumn( 48 | 'image', 49 | \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 50 | 255, 51 | ['nullable' => true], 52 | 'User Photo' 53 | )->addColumn( 54 | 'shop_name', 55 | \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 56 | 255, 57 | ['nullable' => true], 58 | 'Shop Name' 59 | )->addColumn( 60 | 'admin_commission', 61 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 62 | null, 63 | ['nullable' => true], 64 | 'Admin Commission Percentage' 65 | ) 66 | ->addColumn( 67 | 'total_admin_commission', 68 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 69 | null, 70 | ['nullable' => true], 71 | 'Total Admin Commission Percentage' 72 | ) 73 | ->addColumn( 74 | 'total_seller_amount', 75 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 76 | null, 77 | ['nullable' => true], 78 | 'Tatoal Seller Amount' 79 | ) 80 | ->addColumn( 81 | 'total_seller_paid', 82 | \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 83 | null, 84 | ['nullable' => true], 85 | 'Total Seller Paid' 86 | )->addIndex( 87 | $installer->getIdxName('osmansorkar_multicart_userinfo', ['user_id']), 88 | ['user_id'] 89 | )->setComment( 90 | 'MultiCart Profile' 91 | ); 92 | $installer->getConnection()->createTable($table); 93 | } 94 | } -------------------------------------------------------------------------------- /Model/Profile.php: -------------------------------------------------------------------------------- 1 | _init('OsmanSorkar\MultiCart\Model\ResourceModel\Profile'); 23 | } 24 | 25 | /** 26 | * Get identities 27 | * 28 | * @return array 29 | */ 30 | public function getIdentities() 31 | { 32 | return [self::CACHE_TAG . '_' . $this->getId()]; 33 | } 34 | public function getId(){ 35 | return $this->getData(self::ENTITY_ID); 36 | } 37 | public function getUserId(){ 38 | return $this->getData(self::USER_ID); 39 | } 40 | public function getImage(){ 41 | return $this->getData(self::IMAGE); 42 | } 43 | public function getShopName(){ 44 | return $this->getData(self::SHOP_ID); 45 | } 46 | public function getAdminCommission(){ 47 | return $this->getData(self::ADMIN_COMMISSION); 48 | } 49 | public function getTotalAdminCommission(){ 50 | return $this->getData(self::TOTAL_ADMIN_COMMISSION); 51 | } 52 | public function getTotalSelllerAmount(){ 53 | return $this->getData(self::TOTAL_SELLER_AMOUNT); 54 | } 55 | public function getTotalSellerPaid(){ 56 | return $this->getData(self::TOTAL_SELLER_PAID); 57 | } 58 | 59 | public function setId($id){ 60 | $this->setData(self::ENTITY_ID,$id); 61 | return $this; 62 | } 63 | public function setUserId($id){ 64 | $this->setData(self::USER_ID,$id); 65 | return $this; 66 | } 67 | public function setImage($image){ 68 | $this->setData(self::IMAGE,$image); 69 | return $this; 70 | } 71 | public function setShopName($name){ 72 | $this->setData(self::SHOP_NAME,$name); 73 | return $this; 74 | } 75 | public function setAdminCommission($commission){ 76 | $this->setData(self::ADMIN_COMMISSION,$commission); 77 | return $this; 78 | } 79 | public function setTotalAdminCommission($commission){ 80 | $this->setData(self::TOTAL_ADMIN_COMMISSION,$commission); 81 | return $this; 82 | } 83 | public function setTotalSelllerAmount($amount){ 84 | $this->setData(self::TOTAL_SELLER_AMOUNT,$amount); 85 | return $this; 86 | } 87 | public function setTotalSellerPaid($amount){ 88 | $this->setData(self::TOTAL_SELLER_PAID,$amount); 89 | return $this; 90 | } 91 | public function loadProfileById($id){ 92 | $data = $this->getResource()->loadProfileById($id); 93 | if ($data !== false) { 94 | $this->setData($data); 95 | } 96 | return $this; 97 | } 98 | public function getAllProductId(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collection){ 99 | return $collection->create()->addFieldToFilter("product_user_id",$this->getUserId())->getAllIds(); 100 | } 101 | } -------------------------------------------------------------------------------- /Plugin/Block/Adminhtml/System/Account/Edit/Form.php: -------------------------------------------------------------------------------- 1 | _authSession = $authSession; 14 | $this->_sellerProfile = $sellerProfile; 15 | } 16 | 17 | /** 18 | * Get form HTML 19 | * 20 | * @return string 21 | */ 22 | public function aroundGetFormHtml( 23 | \Magento\Backend\Block\System\Account\Edit\Form $subject, 24 | \Closure $proceed 25 | ) 26 | { 27 | $form = $subject->getForm(); 28 | if (is_object($form)) { 29 | 30 | $userId = $this->_authSession->getUser()->getId(); 31 | 32 | $model = $this->_sellerProfile->loadProfileById($userId); 33 | 34 | $fieldset = $form->addFieldset( 35 | 'content_fieldset', 36 | ['legend' => __('Seller Profile'), 'class' => 'fieldset-wide'] 37 | ); 38 | 39 | $fieldset->addField( 40 | 'image', 41 | 'text', 42 | [ 43 | 'name' => 'image', 44 | 'label' => __('Seller Profile Image'), 45 | 'title' => __('Seller Profile Image'), 46 | ] 47 | ); 48 | 49 | $fieldset->addField( 50 | 'shop_name', 51 | 'text', 52 | [ 53 | 'name' => 'shop_name', 54 | 'label' => __('Shope Name'), 55 | 'title' => __('Shope Name'), 56 | ] 57 | ); 58 | 59 | $fieldset->addField( 60 | 'admin_commission', 61 | 'text', 62 | [ 63 | 'name' => 'admin_commission', 64 | 'label' => __('Commisshion Cut'), 65 | 'title' => __('Commisshion Cut'), 66 | 'disabled' => true 67 | ] 68 | ); 69 | $fieldset->addField( 70 | 'total_admin_commission', 71 | 'text', 72 | [ 73 | 'name' => 'total_admin_commission', 74 | 'label' => __('Total Due Comission'), 75 | 'title' => __('Total Due Comission'), 76 | 'disabled' => true 77 | ] 78 | ); 79 | 80 | $fieldset->addField( 81 | 'total_seller_amount', 82 | 'text', 83 | [ 84 | 'name' => 'total_seller_amount', 85 | 'label' => __('Have Pay amount'), 86 | 'title' => __('Have Pay amount'), 87 | 'disabled' => true 88 | ] 89 | ); 90 | 91 | $fieldset->addField( 92 | 'total_seller_paid', 93 | 'text', 94 | [ 95 | 'name' => 'total_seller_paid', 96 | 'label' => __('Have to Pay amount'), 97 | 'title' => __('Have to Pay amount'), 98 | 'disabled' => true 99 | ] 100 | ); 101 | 102 | $form->addValues($model->getData()); 103 | $subject->setForm($form); 104 | } 105 | 106 | return $proceed(); 107 | } 108 | } -------------------------------------------------------------------------------- /view/frontend/templates/seller/account/create.phtml: -------------------------------------------------------------------------------- 1 | 10 | 17 |
18 |
19 |
20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 |
31 |
32 |
33 | 34 |
35 | 36 |
37 |
38 |
39 | 40 |
41 | 42 |
43 |
44 |
45 | 46 |
47 |
48 | 49 |
50 | 51 |
52 | 53 |
54 |
55 |
56 | 57 |
58 | 59 |
60 |
61 |
62 | 63 |
64 |
65 | 66 |
67 |
68 |
69 | -------------------------------------------------------------------------------- /Block/Adminhtml/User/Edit/Tab/Content.php: -------------------------------------------------------------------------------- 1 | _sellerProfile = $sellerProfile; 33 | $this->_request = $request; 34 | parent::__construct($context, $registry, $formFactory, $data); 35 | } 36 | 37 | /** 38 | * Prepare form 39 | * 40 | * @return $this 41 | */ 42 | protected function _prepareForm() 43 | { 44 | 45 | if($this->_request->has("user_id")){ 46 | $userId = $this->_request->get("user_id"); 47 | 48 | $model = $this->_sellerProfile->loadProfileById($userId); 49 | }else{ 50 | $model = $this->_sellerProfile; 51 | } 52 | /** @var $model \OsmanSorkar\Options2Attribute\Model\Post */ 53 | 54 | 55 | /* 56 | * Checking if user have permissions to save information 57 | */ 58 | if ($this->_isAllowedAction('OsmanSorkar_Blog::save')) { 59 | $isElementDisabled = false; 60 | } else { 61 | $isElementDisabled = true; 62 | } 63 | 64 | /** @var \Magento\Framework\Data\Form $form */ 65 | $form = $this->_formFactory->create(); 66 | 67 | $form->setHtmlIdPrefix('seller_'); 68 | 69 | 70 | $fieldset = $form->addFieldset( 71 | 'content_fieldset', 72 | ['legend' => __('Seller Profile'), 'class' => 'fieldset-wide'] 73 | ); 74 | 75 | 76 | 77 | $fieldset->addField( 78 | 'image', 79 | 'text', 80 | [ 81 | 'name' => 'image', 82 | 'label' => __('Seller Profile Image'), 83 | 'title' => __('Seller Profile Image'), 84 | 'disabled' => $isElementDisabled 85 | ] 86 | ); 87 | 88 | $fieldset->addField( 89 | 'shop_name', 90 | 'text', 91 | [ 92 | 'name' => 'shop_name', 93 | 'label' => __('Shope Name'), 94 | 'title' => __('Shope Name'), 95 | 'disabled' => $isElementDisabled 96 | ] 97 | ); 98 | 99 | $fieldset->addField( 100 | 'admin_commission', 101 | 'text', 102 | [ 103 | 'name' => 'admin_commission', 104 | 'label' => __('Commisshion Cut'), 105 | 'title' => __('Commisshion Cut'), 106 | 'disabled' => $isElementDisabled 107 | ] 108 | ); 109 | $fieldset->addField( 110 | 'total_admin_commission', 111 | 'text', 112 | [ 113 | 'name' => 'total_admin_commission', 114 | 'label' => __('Total Due Comission'), 115 | 'title' => __('Total Due Comission'), 116 | 'disabled' => $isElementDisabled 117 | ] 118 | ); 119 | 120 | $fieldset->addField( 121 | 'total_seller_amount', 122 | 'text', 123 | [ 124 | 'name' => 'total_seller_amount', 125 | 'label' => __('Have Pay amount'), 126 | 'title' => __('Have Pay amount'), 127 | 'disabled' => $isElementDisabled 128 | ] 129 | ); 130 | 131 | $fieldset->addField( 132 | 'total_seller_paid', 133 | 'text', 134 | [ 135 | 'name' => 'total_seller_paid', 136 | 'label' => __('Have to Pay amount'), 137 | 'title' => __('Have to Pay amount'), 138 | 'disabled' => $isElementDisabled 139 | ] 140 | ); 141 | 142 | $this->_eventManager->dispatch('adminhtml_multicart_user_edit_tab_content_prepare_form', ['form' => $form]); 143 | $form->setValues($model->getData()); 144 | $this->setForm($form); 145 | 146 | return parent::_prepareForm(); 147 | } 148 | 149 | /** 150 | * Prepare label for tab 151 | * 152 | * @return \Magento\Framework\Phrase 153 | */ 154 | public function getTabLabel() 155 | { 156 | return __('Seller Profile'); 157 | } 158 | 159 | /** 160 | * Prepare title for tab 161 | * 162 | * @return \Magento\Framework\Phrase 163 | */ 164 | public function getTabTitle() 165 | { 166 | return __('Seller Profile'); 167 | } 168 | 169 | /** 170 | * Returns status flag about this tab can be shown or not 171 | * 172 | * @return bool 173 | */ 174 | public function canShowTab() 175 | { 176 | return true; 177 | } 178 | 179 | /** 180 | * Returns status flag about this tab hidden or not 181 | * 182 | * @return bool 183 | */ 184 | public function isHidden() 185 | { 186 | return false; 187 | } 188 | 189 | /** 190 | * Check permission for passed action 191 | * 192 | * @param string $resourceId 193 | * @return bool 194 | */ 195 | protected function _isAllowedAction($resourceId) 196 | { 197 | return $this->_authorization->isAllowed($resourceId); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /Controller/Adminhtml/shipment/Save.php: -------------------------------------------------------------------------------- 1 | shipmentLoader = $shipmentLoader; 42 | $this->labelGenerator = $labelGenerator; 43 | $this->shipmentSender = $shipmentSender; 44 | parent::__construct($context); 45 | } 46 | 47 | /** 48 | * @return bool 49 | */ 50 | protected function _isAllowed() 51 | { 52 | //return $this->_authorization->isAllowed('Magento_Sales::shipment'); 53 | return true; 54 | } 55 | 56 | /** 57 | * Save shipment and order in one transaction 58 | * 59 | * @param \Magento\Sales\Model\Order\Shipment $shipment 60 | * @return $this 61 | */ 62 | protected function _saveShipment($shipment) 63 | { 64 | $shipment->getOrder()->setIsInProcess(true); 65 | $transaction = $this->_objectManager->create( 66 | 'Magento\Framework\DB\Transaction' 67 | ); 68 | $transaction->addObject( 69 | $shipment 70 | )->addObject( 71 | $shipment->getOrder() 72 | )->save(); 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Save shipment 79 | * We can save only new shipment. Existing shipments are not editable 80 | * 81 | * @return void 82 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) 83 | * @SuppressWarnings(PHPMD.NPathComplexity) 84 | */ 85 | public function execute() 86 | { 87 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ 88 | $resultRedirect = $this->resultRedirectFactory->create(); 89 | 90 | $formKeyIsValid = $this->_formKeyValidator->validate($this->getRequest()); 91 | $isPost = $this->getRequest()->isPost(); 92 | if (!$formKeyIsValid || !$isPost) { 93 | $this->messageManager->addError(__('We can\'t save the shipment right now.')); 94 | return $resultRedirect->setPath('seller/order/index'); 95 | } 96 | 97 | $data = $this->getRequest()->getParam('shipment'); 98 | 99 | if (!empty($data['comment_text'])) { 100 | $this->_objectManager->get('Magento\Backend\Model\Session')->setCommentText($data['comment_text']); 101 | } 102 | 103 | try { 104 | $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); 105 | $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); 106 | $this->shipmentLoader->setShipment($data); 107 | $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); 108 | $shipment = $this->shipmentLoader->load(); 109 | if (!$shipment) { 110 | $this->_forward('noroute'); 111 | return; 112 | } 113 | 114 | if (!empty($data['comment_text'])) { 115 | $shipment->addComment( 116 | $data['comment_text'], 117 | isset($data['comment_customer_notify']), 118 | isset($data['is_visible_on_front']) 119 | ); 120 | 121 | $shipment->setCustomerNote($data['comment_text']); 122 | $shipment->setCustomerNoteNotify(isset($data['comment_customer_notify'])); 123 | } 124 | 125 | $shipment->register(); 126 | 127 | $shipment->getOrder()->setCustomerNoteNotify(!empty($data['send_email'])); 128 | $responseAjax = new \Magento\Framework\DataObject(); 129 | $isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label']; 130 | 131 | if ($isNeedCreateLabel) { 132 | $this->labelGenerator->create($shipment, $this->_request); 133 | $responseAjax->setOk(true); 134 | } 135 | 136 | $this->_saveShipment($shipment); 137 | 138 | if (!empty($data['send_email'])) { 139 | $this->shipmentSender->send($shipment); 140 | } 141 | 142 | $shipmentCreatedMessage = __('The shipment has been created.'); 143 | $labelCreatedMessage = __('You created the shipping label.'); 144 | 145 | $this->messageManager->addSuccess( 146 | $isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage : $shipmentCreatedMessage 147 | ); 148 | $this->_objectManager->get('Magento\Backend\Model\Session')->getCommentText(true); 149 | } catch (\Magento\Framework\Exception\LocalizedException $e) { 150 | if ($isNeedCreateLabel) { 151 | $responseAjax->setError(true); 152 | $responseAjax->setMessage($e->getMessage()); 153 | } else { 154 | $this->messageManager->addError($e->getMessage()); 155 | $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]); 156 | } 157 | } catch (\Exception $e) { 158 | $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); 159 | if ($isNeedCreateLabel) { 160 | $responseAjax->setError(true); 161 | $responseAjax->setMessage(__('An error occurred while creating shipping label.')); 162 | } else { 163 | $this->messageManager->addError(__('Cannot save shipment.')); 164 | $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]); 165 | } 166 | } 167 | if ($isNeedCreateLabel) { 168 | $this->getResponse()->representJson($responseAjax->toJson()); 169 | } else { 170 | $this->_redirect('seller/order/view', ['order_id' => $shipment->getOrderId()]); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /view/adminhtml/layout/seller_order_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Product 33 | Item Status 34 | Original Price 35 | Price 36 | Qty 37 | Subtotal 38 | Tax Amount 39 | Tax Percent 40 | Discount Amount 41 | Row Total 42 | 43 | 44 | 45 | 46 | 47 | col-product 48 | col-status 49 | col-price-original 50 | col-price 51 | col-ordered-qty 52 | col-subtotal 53 | col-tax-amount 54 | col-tax-percent 55 | col-discont 56 | col-total 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | order_info 77 | order_tab_info 78 | 79 | 89 | 94 | 95 | order_history 96 | Magento\Sales\Block\Adminhtml\Order\View\Tab\History 97 | 98 | 99 | 100 | order_transactions 101 | sales_transactions.grid.container 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/seller_order_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | seller_order_listing.seller_order_listing_data_source 12 | seller_order_listing.seller_order_listing_data_source 13 | 14 | sales_order_columns 15 | 16 | 17 | add 18 | Create New Order 19 | primary 20 | sales/order_create/start 21 | 22 | 23 | 24 | 25 | 26 | Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider 27 | seller_order_listing_data_source 28 | entity_id 29 | id 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Magento_Ui/js/grid/provider 39 | 40 | 41 | 42 | 43 | 44 | 45 | ui/grid/toolbar 46 | 47 | 48 | 49 | 50 | 51 | 52 | seller_order_listing 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | seller_order_listing.seller_order_listing.sales_order_columns 62 | 63 | Magento_Ui/js/grid/controls/columns 64 | dataGridActions 65 | 66 | 67 | 68 | 69 | 70 | 71 | seller_order_listing.seller_order_listing.sales_order_columns.ids 72 | 73 | 74 | 75 | 76 | 77 | 78 | seller_order_listing.seller_order_listing_data_source 79 | seller_order_listing.seller_order_listing.listing_top.listing_filters_chips 80 | 81 | seller_order_listing.seller_order_listing.listing_top.bookmarks 82 | current.search 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | seller_order_listing.seller_order_listing.sales_order_columns 91 | 92 | seller_order_listing.seller_order_listing.listing_top.bookmarks 93 | current.filters 94 | 95 | 96 | seller_order_listing.seller_order_listing.listing_top.listing_filters 97 | 98 | seller_order_listing.seller_order_listing.sales_order_columns.${ $.index }:visible 99 | 100 | 101 | 102 | 103 | 104 | 105 | Magento\Store\Ui\Component\Listing\Column\Store\Options 106 | 107 | 108 | 109 | All Store Views 110 | store_id 111 | Purchase Point 112 | 113 | 114 | 115 | 116 | 196 | 197 | 198 | 199 | 200 | seller_order_listing.seller_order_listing.listing_top.bookmarks 201 | current.paging 202 | 203 | seller_order_listing.seller_order_listing.sales_order_columns.ids 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | seller_order_listing.seller_order_listing.listing_top.bookmarks 213 | current 214 | 215 | 216 | 217 | seller_order_listing.seller_order_listing.sales_order_columns.actions 218 | applyAction 219 | 220 | view 221 | ${ $.$data.rowIndex } 222 | 223 | 224 | 225 | seller_order_listing.seller_order_listing.listing_top.bookmarks 226 | columns.${ $.index } 227 | current.${ $.storageConfig.root} 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | entity_id 236 | 237 | 238 | 239 | 240 | 241 | 242 | text 243 | desc 244 | ID 245 | 246 | 247 | 248 | 249 | 250 | 251 | ui/grid/cells/html 252 | false 253 | Purchase Point 254 | 255 | 256 | 257 | 258 | 259 | 260 | dateRange 261 | Magento_Ui/js/grid/columns/date 262 | date 263 | Purchase Date 264 | 265 | 266 | 267 | 268 | 269 | 270 | text 271 | Bill-to Name 272 | 273 | 274 | 275 | 276 | 277 | 278 | text 279 | Ship-to Name 280 | 281 | 282 | 283 | 299 | 300 | 301 | Magento\Sales\Ui\Component\Listing\Column\Status\Options 302 | 303 | select 304 | Magento_Ui/js/grid/columns/select 305 | select 306 | Status 307 | 308 | 309 | 310 | 311 | 312 | 313 | text 314 | ui/grid/cells/html 315 | false 316 | Billing Address 317 | 318 | 319 | 320 | 321 | 322 | 323 | text 324 | ui/grid/cells/html 325 | false 326 | Shipping Address 327 | 328 | 329 | 330 | 331 | 332 | 333 | text 334 | false 335 | Shipping Information 336 | 337 | 338 | 339 | 340 | 341 | 342 | text 343 | false 344 | Customer Email 345 | 346 | 347 | 348 | 349 | 350 | Magento\Customer\Ui\Component\Listing\Column\Group\Options 351 | 352 | select 353 | Magento_Ui/js/grid/columns/select 354 | false 355 | select 356 | Customer Group 357 | 358 | 359 | 360 | 361 | 362 | 363 | textRange 364 | false 365 | Subtotal 366 | 367 | 368 | 369 | 370 | 371 | 372 | textRange 373 | false 374 | Shipping and Handling 375 | 376 | 377 | 378 | 379 | 380 | 381 | text 382 | false 383 | Customer Name 384 | 385 | 386 | 387 | 388 | 389 | Magento\Payment\Ui\Component\Listing\Column\Method\Options 390 | 391 | select 392 | Magento_Ui/js/grid/columns/select 393 | false 394 | select 395 | Payment Method 396 | 397 | 398 | 399 | 400 | 401 | 402 | textRange 403 | false 404 | Total Refunded 405 | 406 | 407 | 408 | 409 | 410 | 411 | entity_id 412 | seller/order/view 413 | order_id 414 | 415 | 416 | 417 | 418 | 419 | --------------------------------------------------------------------------------