Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
tablerates.php
Go to the documentation of this file.
1 <?php
8 $resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
9 $connection = $resource->getConnection();
10 $resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
11 $entityTable = $resourceModel->getTable('shipping_tablerate');
13  [
14  'website_id' => 1,
15  'dest_country_id' => 'US',
16  'dest_region_id' => 0,
17  'dest_zip' => '*',
18  'condition_name' => 'package_qty',
19  'condition_value' => 1,
20  'price' => 10,
21  'cost' => 10
22  ];
23 $connection->query(
24  "INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
25  . "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
26  . " :condition_name, :condition_value, :price, :cost);",
27  $data
28 );
$connection
Definition: tablerates.php:9
$data
Definition: tablerates.php:12
$objectManager
Definition: tablerates.php:7
$resourceModel
Definition: tablerates.php:10
$resource
Definition: tablerates.php:8
$entityTable
Definition: tablerates.php:11