| 1 |
<?php |
| 2 |
|
| 3 |
class Mbe_Shipping_Model_Csv_Package_Product implements Mbe_Shipping_Entity_Model_Interface |
| 4 |
{ |
| 5 |
use \Traits\Mbe_Entity_Model_Trait { |
| 6 |
insertRow as protected traitInserRow; |
| 7 |
truncate as protected traitTruncate; |
| 8 |
tableExists as protected traitTableExists; |
| 9 |
insertRow as protected traitInsertRow; |
| 10 |
updateRow as protected traitUpdateRow; |
| 11 |
} |
| 12 |
|
| 13 |
public function tableExists() { |
| 14 |
return $this->traitTableExists($this->getTableName()); |
| 15 |
} |
| 16 |
|
| 17 |
public function truncate() { |
| 18 |
return $this->traitTruncate($this->getTableName()); |
| 19 |
} |
| 20 |
|
| 21 |
public function insertRow($row ) { |
| 22 |
return $this->traitInserRow($this->getTableName(), $row); |
| 23 |
} |
| 24 |
|
| 25 |
public function updateRow($id, $row ) { |
| 26 |
return $this->traitUpdateRow($this->getTableName(), $id, $row); |
| 27 |
} |
| 28 |
|
| 29 |
public function getTableName() { |
| 30 |
global $wpdb; |
| 31 |
return $wpdb->prefix . Mbe_Shipping_Helper_Data::MBE_CSV_PACKAGES_PRODUCT_TABLE_NAME; |
| 32 |
} |
| 33 |
|
| 34 |
public function getSqlCreate() { |
| 35 |
global $wpdb; |
| 36 |
$charset = $wpdb->get_charset_collate(); |
| 37 |
|
| 38 |
return "CREATE TABLE " . $this->getTableName() . " ( |
| 39 |
custom_package tinyint(1) null , |
| 40 |
single_parcel tinyint(1) null , |
| 41 |
product_sku varchar(64) not null , |
| 42 |
package_code varchar(50) not null , |
| 43 |
id int(10) unsigned auto_increment , |
| 44 |
primary key (id), |
| 45 |
unique key MBE_PKG_PROD_PACKAGE_PRODUCT_UNIQUE (package_code, product_sku), |
| 46 |
unique key MBE_PKG_PROD_PRODUCT_SKU (product_sku), |
| 47 |
key MBE_PKG_PROD_PACKAGE_CODE (package_code) |
| 48 |
) $charset;"; |
| 49 |
} |
| 50 |
|
| 51 |
} |