tablerates.php 1.0 KB

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  7. $resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
  8. $connection = $resource->getConnection();
  9. $resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
  10. $entityTable = $resourceModel->getTable('shipping_tablerate');
  11. $data =
  12. [
  13. 'website_id' => 1,
  14. 'dest_country_id' => 'US',
  15. 'dest_region_id' => 0,
  16. 'dest_zip' => '*',
  17. 'condition_name' => 'package_qty',
  18. 'condition_value' => 1,
  19. 'price' => 10,
  20. 'cost' => 10
  21. ];
  22. $connection->query(
  23. "INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
  24. . "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
  25. . " :condition_name, :condition_value, :price, :cost);",
  26. $data
  27. );