123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- <?php
- /**
- * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
- */
- namespace Temando\Shipping\Setup;
- use Magento\Framework\DB\Adapter\AdapterInterface;
- use Magento\Framework\DB\Ddl\Table;
- use Magento\Framework\Setup\SchemaSetupInterface;
- use Temando\Shipping\Api\Data\Checkout\AddressInterface;
- use Temando\Shipping\Api\Data\Delivery\CollectionPointSearchRequestInterface;
- use Temando\Shipping\Api\Data\Delivery\OrderCollectionPointInterface;
- use Temando\Shipping\Api\Data\Delivery\OrderPickupLocationInterface;
- use Temando\Shipping\Api\Data\Delivery\PickupLocationSearchRequestInterface;
- use Temando\Shipping\Api\Data\Delivery\QuoteCollectionPointInterface;
- use Temando\Shipping\Api\Data\Delivery\QuotePickupLocationInterface;
- use Temando\Shipping\Api\Data\Order\OrderReferenceInterface;
- use Temando\Shipping\Api\Data\Shipment\ShipmentReferenceInterface;
- /**
- * Schema setup for use during installation / upgrade
- *
- * @package Temando\Shipping\Setup
- * @author Christoph Aßmann <christoph.assmann@netresearch.de>
- * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
- * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @link https://www.temando.com/
- */
- class SetupSchema
- {
- const CHECKOUT_CONNECTION_NAME = 'checkout';
- const SALES_CONNECTION_NAME = 'sales';
- const TABLE_SHIPMENT = 'temando_shipment';
- const TABLE_ORDER = 'temando_order';
- const TABLE_CHECKOUT_ADDRESS = 'temando_checkout_address';
- const TABLE_COLLECTION_POINT_SEARCH = 'temando_collection_point_search';
- const TABLE_QUOTE_COLLECTION_POINT = 'temando_quote_collection_point';
- const TABLE_ORDER_COLLECTION_POINT = 'temando_order_collection_point';
- const TABLE_PICKUP_LOCATION_SEARCH = 'temando_pickup_location_search';
- const TABLE_QUOTE_PICKUP_LOCATION = 'temando_quote_pickup_location';
- const TABLE_ORDER_PICKUP_LOCATION = 'temando_order_pickup_location';
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createShipmentTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::SALES_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_SHIPMENT, self::SALES_CONNECTION_NAME)
- );
- $table->addColumn(
- ShipmentReferenceInterface::ENTITY_ID,
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- ShipmentReferenceInterface::SHIPMENT_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false],
- 'Magento Shipment Id'
- );
- $table->addColumn(
- ShipmentReferenceInterface::EXT_SHIPMENT_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'External Shipment Id'
- );
- $table->addColumn(
- ShipmentReferenceInterface::EXT_LOCATION_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'External Location Id'
- );
- $table->addColumn(
- ShipmentReferenceInterface::EXT_TRACKING_URL,
- Table::TYPE_TEXT,
- 255,
- [],
- 'External Tracking Url'
- );
- $table->addColumn(
- ShipmentReferenceInterface::EXT_TRACKING_REFERENCE,
- Table::TYPE_TEXT,
- 255,
- [],
- 'External Tracking Reference'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_SHIPMENT,
- ShipmentReferenceInterface::SHIPMENT_ID,
- 'sales_shipment',
- 'entity_id'
- ),
- ShipmentReferenceInterface::SHIPMENT_ID,
- $installer->getTable('sales_shipment', self::SALES_CONNECTION_NAME),
- 'entity_id',
- Table::ACTION_CASCADE
- );
- $table->addIndex(
- $installer->getIdxName(
- self::TABLE_SHIPMENT,
- [ShipmentReferenceInterface::SHIPMENT_ID, ShipmentReferenceInterface::EXT_SHIPMENT_ID],
- AdapterInterface::INDEX_TYPE_UNIQUE
- ),
- [ShipmentReferenceInterface::SHIPMENT_ID, ShipmentReferenceInterface::EXT_SHIPMENT_ID],
- ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
- );
- $table->setComment(
- 'Temando Shipment'
- );
- $installer->getConnection(self::SALES_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createOrderTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::SALES_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_ORDER, self::SALES_CONNECTION_NAME)
- );
- $table->addColumn(
- OrderReferenceInterface::ENTITY_ID,
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- OrderReferenceInterface::ORDER_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false],
- 'Magento Order Id'
- );
- $table->addColumn(
- OrderReferenceInterface::EXT_ORDER_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'Temando Order Id'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_ORDER,
- OrderReferenceInterface::ORDER_ID,
- 'sales_order',
- 'entity_id'
- ),
- OrderReferenceInterface::ORDER_ID,
- $installer->getTable('sales_order', self::SALES_CONNECTION_NAME),
- 'entity_id',
- Table::ACTION_CASCADE
- );
- $table->setComment(
- 'Temando Order'
- );
- $installer->getConnection(self::SALES_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createAddressTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_CHECKOUT_ADDRESS, self::CHECKOUT_CONNECTION_NAME)
- );
- $table->addColumn(
- AddressInterface::ENTITY_ID,
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- AddressInterface::SHIPPING_ADDRESS_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false],
- 'Magento Quote Address Id'
- );
- $table->addColumn(
- AddressInterface::SERVICE_SELECTION,
- Table::TYPE_TEXT,
- null,
- [],
- 'Value Added Services'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_CHECKOUT_ADDRESS,
- AddressInterface::SHIPPING_ADDRESS_ID,
- 'quote_address',
- 'address_id'
- ),
- AddressInterface::SHIPPING_ADDRESS_ID,
- $installer->getTable('quote_address', self::CHECKOUT_CONNECTION_NAME),
- 'address_id',
- Table::ACTION_CASCADE
- );
- $table->setComment(
- 'Temando Checkout Address'
- );
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- */
- public function setShipmentOriginLocationNullable(SchemaSetupInterface $installer)
- {
- $tableName = $installer->getTable(self::TABLE_SHIPMENT, self::SALES_CONNECTION_NAME);
- $installer->getConnection(self::SALES_CONNECTION_NAME)->modifyColumn(
- $tableName,
- ShipmentReferenceInterface::EXT_LOCATION_ID,
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 64,
- 'nullable' => true,
- ]
- );
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createCollectionPointSearchTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_COLLECTION_POINT_SEARCH, self::CHECKOUT_CONNECTION_NAME)
- );
- $table->addColumn(
- CollectionPointSearchRequestInterface::SHIPPING_ADDRESS_ID,
- Table::TYPE_INTEGER,
- 10,
- ['unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- CollectionPointSearchRequestInterface::COUNTRY_ID,
- Table::TYPE_TEXT,
- 2,
- ['nullable' => false],
- 'Country Code'
- );
- $table->addColumn(
- CollectionPointSearchRequestInterface::POSTCODE,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Zip/Postal Code'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_COLLECTION_POINT_SEARCH,
- CollectionPointSearchRequestInterface::SHIPPING_ADDRESS_ID,
- 'quote_address',
- 'address_id'
- ),
- CollectionPointSearchRequestInterface::SHIPPING_ADDRESS_ID,
- $installer->getTable('quote_address', self::CHECKOUT_CONNECTION_NAME),
- 'address_id',
- Table::ACTION_CASCADE
- );
- $countryTable = $installer->getTable('directory_country', self::CHECKOUT_CONNECTION_NAME);
- if ($installer->tableExists($countryTable, self::CHECKOUT_CONNECTION_NAME)) {
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_COLLECTION_POINT_SEARCH,
- CollectionPointSearchRequestInterface::COUNTRY_ID,
- 'directory_country',
- 'country_id'
- ),
- CollectionPointSearchRequestInterface::COUNTRY_ID,
- $countryTable,
- 'country_id',
- Table::ACTION_NO_ACTION
- );
- }
- $table->setComment('Collection Point Search');
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createQuoteCollectionPointTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_QUOTE_COLLECTION_POINT, self::CHECKOUT_CONNECTION_NAME)
- );
- $table->addColumn(
- QuoteCollectionPointInterface::ENTITY_ID,
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false],
- 'Quote Address Id'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::COLLECTION_POINT_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'Collection Point Id'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::NAME,
- Table::TYPE_TEXT,
- 255,
- [],
- 'Name'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::COUNTRY,
- Table::TYPE_TEXT,
- 2,
- ['nullable' => false],
- 'Country Code'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::REGION,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Region'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::POSTCODE,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Zip/Postal Code'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::CITY,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'City'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::STREET,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Street'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::OPENING_HOURS,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Opening Hours'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::SHIPPING_EXPERIENCES,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Shipping Experiences'
- );
- $table->addColumn(
- QuoteCollectionPointInterface::SELECTED,
- Table::TYPE_SMALLINT,
- null,
- ['unsigned' => true, 'nullable' => false, 'default' => 0],
- 'Is Selected'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_QUOTE_COLLECTION_POINT,
- QuoteCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- self::TABLE_COLLECTION_POINT_SEARCH,
- CollectionPointSearchRequestInterface::SHIPPING_ADDRESS_ID
- ),
- QuoteCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- $installer->getTable(self::TABLE_COLLECTION_POINT_SEARCH, self::CHECKOUT_CONNECTION_NAME),
- CollectionPointSearchRequestInterface::SHIPPING_ADDRESS_ID,
- Table::ACTION_CASCADE
- );
- $table->setComment('Quote Collection Point Entity');
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createOrderCollectionPointTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::SALES_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_ORDER_COLLECTION_POINT, self::SALES_CONNECTION_NAME)
- );
- $table->addColumn(
- OrderCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- OrderCollectionPointInterface::COLLECTION_POINT_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'Collection Point Id'
- );
- $table->addColumn(
- OrderCollectionPointInterface::NAME,
- Table::TYPE_TEXT,
- 255,
- [],
- 'Name'
- );
- $table->addColumn(
- OrderCollectionPointInterface::COUNTRY,
- Table::TYPE_TEXT,
- 2,
- ['nullable' => false],
- 'Country Code'
- );
- $table->addColumn(
- OrderCollectionPointInterface::REGION,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Region'
- );
- $table->addColumn(
- OrderCollectionPointInterface::POSTCODE,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Zip/Postal Code'
- );
- $table->addColumn(
- OrderCollectionPointInterface::CITY,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'City'
- );
- $table->addColumn(
- OrderCollectionPointInterface::STREET,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Street'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_QUOTE_COLLECTION_POINT,
- OrderCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- 'sales_order_address',
- 'entity_id'
- ),
- OrderCollectionPointInterface::RECIPIENT_ADDRESS_ID,
- $installer->getTable('sales_order_address', self::SALES_CONNECTION_NAME),
- 'entity_id',
- Table::ACTION_CASCADE
- );
- $table->setComment('Order Collection Point Entity');
- $installer->getConnection(self::SALES_CONNECTION_NAME)->createTable($table);
- }
- /**
- * Add an indicator for collection point checkout being in progress.
- *
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- * @return void
- */
- public function addCollectionPointSearchPendingColumn(SchemaSetupInterface $installer)
- {
- $tableName = $installer->getTable(self::TABLE_COLLECTION_POINT_SEARCH, self::CHECKOUT_CONNECTION_NAME);
- // allow empty values for pending searches
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->modifyColumn(
- $tableName,
- CollectionPointSearchRequestInterface::COUNTRY_ID,
- ['type' => Table::TYPE_TEXT, 'length' => 2, 'nullable' => true]
- );
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->modifyColumn(
- $tableName,
- CollectionPointSearchRequestInterface::POSTCODE,
- ['type' => Table::TYPE_TEXT, 'length' => 255, 'nullable' => true]
- );
- // add pending indicator
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->addColumn(
- $tableName,
- CollectionPointSearchRequestInterface::PENDING,
- [
- 'type' => Table::TYPE_BOOLEAN,
- 'nullable' => false,
- 'default' => 0,
- 'comment' => 'Pending'
- ]
- );
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createPickupLocationSearchTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_PICKUP_LOCATION_SEARCH, self::CHECKOUT_CONNECTION_NAME)
- );
- $table->addColumn(
- PickupLocationSearchRequestInterface::SHIPPING_ADDRESS_ID,
- Table::TYPE_INTEGER,
- 10,
- ['unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- PickupLocationSearchRequestInterface::ACTIVE,
- Table::TYPE_BOOLEAN,
- 2,
- ['nullable' => false],
- 'Active'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_PICKUP_LOCATION_SEARCH,
- PickupLocationSearchRequestInterface::SHIPPING_ADDRESS_ID,
- 'quote_address',
- 'address_id'
- ),
- PickupLocationSearchRequestInterface::SHIPPING_ADDRESS_ID,
- $installer->getTable('quote_address', self::CHECKOUT_CONNECTION_NAME),
- 'address_id',
- Table::ACTION_CASCADE
- );
- $table->setComment('Pickup Location Search');
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createQuotePickupLocationTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_QUOTE_PICKUP_LOCATION, self::CHECKOUT_CONNECTION_NAME)
- );
- $table->addColumn(
- QuotePickupLocationInterface::ENTITY_ID,
- Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- QuotePickupLocationInterface::RECIPIENT_ADDRESS_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false],
- 'Quote Address Id'
- );
- $table->addColumn(
- QuotePickupLocationInterface::PICKUP_LOCATION_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'Pickup Location Id'
- );
- $table->addColumn(
- QuotePickupLocationInterface::NAME,
- Table::TYPE_TEXT,
- 255,
- [],
- 'Name'
- );
- $table->addColumn(
- QuotePickupLocationInterface::COUNTRY,
- Table::TYPE_TEXT,
- 2,
- ['nullable' => false],
- 'Country Code'
- );
- $table->addColumn(
- QuotePickupLocationInterface::REGION,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Region'
- );
- $table->addColumn(
- QuotePickupLocationInterface::POSTCODE,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Zip/Postal Code'
- );
- $table->addColumn(
- QuotePickupLocationInterface::CITY,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'City'
- );
- $table->addColumn(
- QuotePickupLocationInterface::STREET,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Street'
- );
- $table->addColumn(
- QuotePickupLocationInterface::OPENING_HOURS,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Opening Hours'
- );
- $table->addColumn(
- QuotePickupLocationInterface::SHIPPING_EXPERIENCES,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Shipping Experiences'
- );
- $table->addColumn(
- QuotePickupLocationInterface::SELECTED,
- Table::TYPE_SMALLINT,
- null,
- ['unsigned' => true, 'nullable' => false, 'default' => 0],
- 'Is Selected'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_QUOTE_PICKUP_LOCATION,
- QuotePickupLocationInterface::RECIPIENT_ADDRESS_ID,
- self::TABLE_PICKUP_LOCATION_SEARCH,
- PickupLocationSearchRequestInterface::SHIPPING_ADDRESS_ID
- ),
- QuotePickupLocationInterface::RECIPIENT_ADDRESS_ID,
- $installer->getTable(self::TABLE_PICKUP_LOCATION_SEARCH, self::CHECKOUT_CONNECTION_NAME),
- PickupLocationSearchRequestInterface::SHIPPING_ADDRESS_ID,
- Table::ACTION_CASCADE
- );
- $table->setComment('Quote Pickup Location Entity');
- $installer->getConnection(self::CHECKOUT_CONNECTION_NAME)->createTable($table);
- }
- /**
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- *
- * @return void
- * @throws \Zend_Db_Exception
- */
- public function createOrderPickupLocationTable(SchemaSetupInterface $installer)
- {
- $table = $installer->getConnection(self::SALES_CONNECTION_NAME)->newTable(
- $installer->getTable(self::TABLE_ORDER_PICKUP_LOCATION, self::SALES_CONNECTION_NAME)
- );
- $table->addColumn(
- OrderPickupLocationInterface::RECIPIENT_ADDRESS_ID,
- Table::TYPE_INTEGER,
- null,
- ['unsigned' => true, 'nullable' => false, 'primary' => true],
- 'Entity Id'
- );
- $table->addColumn(
- OrderPickupLocationInterface::PICKUP_LOCATION_ID,
- Table::TYPE_TEXT,
- 64,
- ['nullable' => false],
- 'Pickup Location Id'
- );
- $table->addColumn(
- OrderPickupLocationInterface::NAME,
- Table::TYPE_TEXT,
- 255,
- [],
- 'Name'
- );
- $table->addColumn(
- OrderPickupLocationInterface::COUNTRY,
- Table::TYPE_TEXT,
- 2,
- ['nullable' => false],
- 'Country Code'
- );
- $table->addColumn(
- OrderPickupLocationInterface::REGION,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Region'
- );
- $table->addColumn(
- OrderPickupLocationInterface::POSTCODE,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'Zip/Postal Code'
- );
- $table->addColumn(
- OrderPickupLocationInterface::CITY,
- Table::TYPE_TEXT,
- 255,
- ['nullable' => false],
- 'City'
- );
- $table->addColumn(
- OrderPickupLocationInterface::STREET,
- Table::TYPE_TEXT,
- null,
- ['nullable' => false],
- 'Street'
- );
- $table->addForeignKey(
- $installer->getFkName(
- self::TABLE_ORDER_PICKUP_LOCATION,
- OrderPickupLocationInterface::RECIPIENT_ADDRESS_ID,
- 'sales_order_address',
- 'entity_id'
- ),
- OrderPickupLocationInterface::RECIPIENT_ADDRESS_ID,
- $installer->getTable('sales_order_address', self::SALES_CONNECTION_NAME),
- 'entity_id',
- Table::ACTION_CASCADE
- );
- $table->setComment('Order Pickup Location Entity');
- $installer->getConnection(self::SALES_CONNECTION_NAME)->createTable($table);
- }
- /**
- * Add distance property to delivery location tables.
- *
- * @param SchemaSetupInterface|\Magento\Framework\Module\Setup $installer
- * @return void
- */
- public function addDeliveryLocationDistanceColumn(SchemaSetupInterface $installer)
- {
- $tableName = $installer->getTable(self::TABLE_QUOTE_COLLECTION_POINT, self::CHECKOUT_CONNECTION_NAME);
- $installer
- ->getConnection(self::CHECKOUT_CONNECTION_NAME)
- ->addColumn(
- $tableName,
- QuoteCollectionPointInterface::DISTANCE,
- [
- 'type' => Table::TYPE_INTEGER,
- 'unsigned' => true,
- 'nullable' => true,
- 'comment' => 'Distance in Meters'
- ]
- );
- $tableName = $installer->getTable(self::TABLE_QUOTE_PICKUP_LOCATION, self::CHECKOUT_CONNECTION_NAME);
- $installer
- ->getConnection(self::CHECKOUT_CONNECTION_NAME)
- ->addColumn(
- $tableName,
- QuotePickupLocationInterface::DISTANCE,
- [
- 'type' => Table::TYPE_INTEGER,
- 'unsigned' => true,
- 'nullable' => true,
- 'comment' => 'Distance in Meters'
- ]
- );
- }
- }
|