vendor/store.shopware.com/webkulmvmarketplace/src/WebkulMVMarketplace.php line 13

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Webkul\MultiVendor;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Defaults;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  9. use Shopware\Core\Framework\Uuid\Uuid;
  10. class WebkulMVMarketplace extends Plugin
  11. {
  12.     public function update(UpdateContext $updateContext): void
  13.     {
  14.         $connection $this->container->get(Connection::class);
  15.         $connection->executeUpdate('DELETE FROM `marketplace_email_template` ');
  16.         $logo $_SERVER['APP_URL'].'/bundles/webkulmvmarketplace/administration/images/webkul-logo.png';
  17.         $connection->insert('marketplace_email_template',['id'=> Uuid::randomBytes(), 'technical_name'=> 'update_order_status''name'=>'Order status has been updated''subject'=> 'Order status has been updated''message'=> '<div style="color: rgb(102, 102, 102);"><p><br><img src="'.$logo.'" style="width: 334.005px; height: 71px;"></p><p style="font-size: 16px; color: rgb(32, 151, 197); border-bottom: 1px solid;">Marketplace Message from {config_name}</p><br>Hi&nbsp;<span style="color: rgb(32, 151, 197); font-size: 14px;">{config_owner}</span>,<br></div><div style="color: rgb(102, 102, 102);"><br></div><div style="color: rgb(102, 102, 102);">Order status has been updated by the seller.</div><div style="color: rgb(102, 102, 102);">These are order details of your product(s)</div><div style="color: rgb(102, 102, 102);"><br></div><div style="color: rgb(102, 102, 102);">{order}</div><div style="color: rgb(102, 102, 102);"><br>Thanks,<br><span style="color: rgb(32, 151, 197);">{config_name}</span></div>''created_at'=> (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
  18.         $connection->insert('marketplace_email_template',['id'=> Uuid::randomBytes(), 'technical_name'=> 'customer_apply_sellership''name'=>'Customer Apply for SellerShip (To Admin)''subject'=> 'Customer Apply for PartnerShip''message'=> '<p style="color: rgb(102, 102, 102);"><br><img src="'.$logo.'" style="width: 338.71px; height: 72px;"></p><p style="font-size: 16px; color: rgb(32, 151, 197); border-bottom: 1px solid;">Marketplace Message from {config_name}</p><p><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">Hi&nbsp;</span><span style="color: rgb(32, 151, 197); font-size: 14px;">{config_owner}</span><span style="color: rgb(102, 102, 102);">,</span><br style="color: rgb(102, 102, 102);"><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">Customer Applied for PartnerShip and has been approved through Auto Approve seller -&nbsp;</span><span style="color: rgb(32, 151, 197);">&nbsp;<span style="font-weight: bold;">{seller_name}</span></span><span style="font-weight: bold; color: rgb(32, 151, 197);">&nbsp;</span><br style="color: rgb(102, 102, 102);"><br style="color: rgb(102, 102, 102);"><span style="color: rgb(102, 102, 102);">Thanks,</span><br style="color: rgb(102, 102, 102);"><span style="color: rgb(32, 151, 197);">{config_name}</span><br></p>''created_at'=> (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
  19.         $connection->insert('marketplace_email_template',['id'=> Uuid::randomBytes(), 'technical_name'=> 'confirm_sellership_message''name'=>'Customer Apply for SellerShip (To Customer)''subject'=> 'Thanks For Applying for SellerShip''message'=> '<div style="color: rgb(102, 102, 102);"><p><img src="'.$logo.'" style="width: 334.005px; height: 71px;"><br></p><p style="font-size: 16px; color: rgb(32, 151, 197); border-bottom: 1px solid;">Marketplace Message from {config_name}</p><br>Hi&nbsp;<span style="color: rgb(32, 151, 197); font-size: 14px;">{seller_name}</span>,<br><br>Thanks for&nbsp;<span style="line-height: 20px;">registering at</span>&nbsp;<span style="color: rgb(32, 151, 197);"><span style="font-weight: bold;">{config_name}.&nbsp;</span></span>Your Request for Sellership has been Approved successfully.</div><div style="color: rgb(102, 102, 102);">Be ready to Add your Product at<span style="color: rgb(32, 151, 197);">&nbsp;<span style="font-weight: bold;">{config_name}</span></span><br><br>Thanks,<br><span style="color: rgb(32, 151, 197);">{config_name}</span></div>''created_at'=> (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
  20.         $connection->insert('marketplace_email_template',['id'=> Uuid::randomBytes(), 'technical_name'=> 'low_stock_mail''name'=>'Low Stock Mail Notification''subject'=> 'Low Stock Mail''message'=> '<div style="color: rgb(102, 102, 102);"><p><img src="'.$logo.'" style="width: 334.005px; height: 71px;"></p><p style="font-size: 16px; color: rgb(32, 151, 197); border-bottom: 1px solid;">Marketplace Message from {config_name}</p><br>Hi {seller_name},<br><br>Your product {product_name} is at low stock. Kindly check for the same.&nbsp;</div><div style="color: rgb(102, 102, 102);"><br>Thanks,<br><span style="color: rgb(32, 151, 197);">{config_name}</span></div>''created_at'=> (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
  21.         $connection->insert('marketplace_email_template',['id'=> Uuid::randomBytes(), 'technical_name'=> 'product_approved''name'=>'Seller Product Approved''subject'=> 'Your Product has been approved''message'=> '<div style="color: rgb(102, 102, 102);"><p><img src="'.$logo.'" style="width: 334.005px; height: 71px;"></p><p style="font-size: 16px; color: rgb(32, 151, 197); border-bottom: 1px solid;">Marketplace Message from {config_name}</p><br>Hi {seller_name},<br><br>Your Product has been passed our rules and regulations so we are approving your Product {product_name}  please do maintain your store like this. Thanks for add your product at {config_name}.&nbsp;</div><div style="color: rgb(102, 102, 102);"><br>Thanks,<br><span style="color: rgb(32, 151, 197);">{config_name}</span></div>''created_at'=> (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
  22.         $table $connection->fetchColumn('SHOW TABLES LIKE "marketplace_seller"');
  23.         if($table) {
  24.             $column $connection->fetchColumn('SHOW COLUMNS FROM marketplace_seller LIKE "email"');
  25.             if(!$column) {
  26.                 $connection->executeUpdate('ALTER TABLE marketplace_seller ADD COLUMN phone VARCHAR(15) NULL AFTER social_sites, ADD COLUMN store_address VARCHAR(255) NULL AFTER social_sites, ADD COLUMN email VARCHAR(100) NULL AFTER social_sites');
  27.             }
  28.         }
  29.     }
  30.     public function install(InstallContext $installContext): void
  31.     {
  32.         $connection $this->container->get(Connection::class);
  33.         $table $connection->fetchColumn('SHOW TABLES LIKE "marketplace_seller"');
  34.         if($table) {
  35.             $column $connection->fetchColumn('SHOW COLUMNS FROM marketplace_seller LIKE "email"');
  36.             if(!$column) {
  37.                 $connection->executeUpdate('ALTER TABLE marketplace_seller ADD COLUMN phone VARCHAR(15) NULL AFTER social_sites, ADD COLUMN store_address VARCHAR(255) NULL AFTER social_sites, ADD COLUMN email VARCHAR(100) NULL AFTER social_sites');
  38.             }
  39.         }
  40.     }
  41.     
  42.     public function uninstall(UninstallContext $context): void
  43.     {
  44.         parent::uninstall($context);
  45.         if ($context->keepUserData()) {
  46.             return;
  47.         }
  48.         $connection $this->container->get(Connection::class);
  49.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_commission`');
  50.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_order`');
  51.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_product`');
  52.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_review`');
  53.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_seller`');
  54.         $connection->executeUpdate('DROP TABLE IF EXISTS `marketplace_email_template`');
  55.     }
  56. }