ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/fixed_product_attribute_rollback.php');
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
|
||||
$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class);
|
||||
|
||||
$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product');
|
||||
$defaultSetId = $objectManager->create(\Magento\Catalog\Model\Product::class)->getDefaultAttributeSetid();
|
||||
|
||||
$attributeGroupId = $attributeSet->getDefaultGroupId($entityType->getDefaultAttributeSetId());
|
||||
|
||||
$attributeData = [
|
||||
'entity_type_id' => $entityType->getId(),
|
||||
'attribute_code' => 'fixed_product_attribute',
|
||||
'backend_model' => 'Magento\Weee\Model\Attribute\Backend\Weee\Tax',
|
||||
'is_required' => 0,
|
||||
'is_user_defined' => 1,
|
||||
'is_static' => 1,
|
||||
'attribute_set_id' => $defaultSetId,
|
||||
'attribute_group_id' => $attributeGroupId,
|
||||
'frontend_input' => 'weee',
|
||||
'frontend_label' => 'fixed product tax',
|
||||
'is_used_in_grid' => '1',
|
||||
];
|
||||
|
||||
/** @var \Magento\Catalog\Model\Entity\Attribute $attribute */
|
||||
$attribute = $objectManager->create(\Magento\Eav\Model\Entity\Attribute::class);
|
||||
$attribute->setData($attributeData);
|
||||
$attribute->save();
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/* @var \Magento\Eav\Model\Entity\Attribute $attribute */
|
||||
$attribute = $objectManager->get(\Magento\Eav\Model\Entity\Attribute::class);
|
||||
$attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'fixed_product_attribute');
|
||||
$attribute->delete();
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/** @var \Magento\Catalog\Setup\CategorySetup $installer */
|
||||
$installer = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class
|
||||
);
|
||||
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
|
||||
$entityModel = Bootstrap::getObjectManager()->create(\Magento\Eav\Model\Entity::class);
|
||||
$entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId();
|
||||
$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
|
||||
$attribute = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$attribute->setAttributeCode(
|
||||
'fpt_for_all'
|
||||
)->setEntityTypeId(
|
||||
$entityTypeId
|
||||
)->setAttributeGroupId(
|
||||
$groupId
|
||||
)->setAttributeSetId(
|
||||
$attributeSetId
|
||||
)->setFrontendLabel(
|
||||
'fpt_for_all_front_label'
|
||||
)->setFrontendInput(
|
||||
'weee'
|
||||
)->setIsUserDefined(
|
||||
1
|
||||
)->save();
|
||||
|
||||
/** @var Product $product */
|
||||
$product = Bootstrap::getObjectManager()->create(Product::class);
|
||||
$product->setTypeId(
|
||||
'simple'
|
||||
)->setAttributeSetId(
|
||||
$attributeSetId
|
||||
)->setStoreId(
|
||||
1
|
||||
)->setWebsiteIds(
|
||||
[1]
|
||||
)->setVisibility(
|
||||
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
|
||||
)->setStatus(
|
||||
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
|
||||
)->setStockData(
|
||||
['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1]
|
||||
)->setName(
|
||||
'Simple Product FPT'
|
||||
)->setSku(
|
||||
'simple-with-ftp'
|
||||
)->setPrice(
|
||||
100
|
||||
)->setFptForAll(
|
||||
[['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 12.70, 'delete' => '']]
|
||||
)->save();
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
|
||||
|
||||
$product = $product->loadByAttribute('sku', 'simple-with-ftp');
|
||||
if ($product && $product->getId()) {
|
||||
$product->delete();
|
||||
}
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
|
||||
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
|
||||
$attribute->load('fpt_for_all', 'attribute_code');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt.php');
|
||||
|
||||
/** @var \Magento\Catalog\Setup\CategorySetup $installer */
|
||||
$installer = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Setup\CategorySetup::class
|
||||
);
|
||||
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
|
||||
$entityModel = Bootstrap::getObjectManager()->create(\Magento\Eav\Model\Entity::class);
|
||||
$entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId();
|
||||
$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
|
||||
$attribute = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
|
||||
);
|
||||
$attribute->setAttributeCode(
|
||||
'fixed_product_attribute'
|
||||
)->setEntityTypeId(
|
||||
$entityTypeId
|
||||
)->setAttributeGroupId(
|
||||
$groupId
|
||||
)->setAttributeSetId(
|
||||
$attributeSetId
|
||||
)->setFrontendLabel(
|
||||
'fixed_product_attribute_front_label'
|
||||
)->setFrontendInput(
|
||||
'weee'
|
||||
)->setIsUserDefined(
|
||||
1
|
||||
)->save();
|
||||
|
||||
/** @var $product \Magento\Catalog\Model\Product */
|
||||
$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
|
||||
|
||||
$product = $product->loadByAttribute('sku', 'simple-with-ftp');
|
||||
if ($product && $product->getId()) {
|
||||
$product->setFixedProductAttribute(
|
||||
[['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10.00, 'delete' => '']]
|
||||
)->save();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
|
||||
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
|
||||
$attribute->load('fixed_product_attribute', 'attribute_code');
|
||||
if ($attribute->getId()) {
|
||||
$attribute->delete();
|
||||
}
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt_rollback.php');
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Quote\Api\CartRepositoryInterface;
|
||||
use Magento\Quote\Api\Data\AddressInterface;
|
||||
use Magento\Quote\Api\Data\PaymentInterface;
|
||||
use Magento\Quote\Model\Quote;
|
||||
use Magento\Quote\Model\Quote\Address\Rate;
|
||||
use Magento\Quote\Model\Quote\Item;
|
||||
use Magento\Quote\Model\QuoteFactory;
|
||||
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\ObjectManager;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var QuoteFactory $quoteFactory */
|
||||
$quoteFactory = Bootstrap::getObjectManager()->get(QuoteFactory::class);
|
||||
/** @var QuoteResource $quoteResource */
|
||||
$quoteResource = Bootstrap::getObjectManager()->get(QuoteResource::class);
|
||||
/** @var StoreManagerInterface $storeManager */
|
||||
$storeManager = $objectManager->get(StoreManagerInterface::class);
|
||||
/** @var CartRepositoryInterface $quoteRepository */
|
||||
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
|
||||
$store = $storeManager->getStore();
|
||||
/** @var Quote $quote */
|
||||
$quote = $quoteFactory->create();
|
||||
$quote->setReservedOrderId('multishipping_fpt_quote_id')
|
||||
->setCustomerEmail('customer001@test.com')
|
||||
->setStoreId($storeManager->getStore()->getId());
|
||||
|
||||
$shipping = [
|
||||
'firstname' => 'Jonh',
|
||||
'lastname' => 'Doe',
|
||||
'telephone' => '0333-233-221',
|
||||
'street' => ['Main Division 1'],
|
||||
'city' => 'Culver City',
|
||||
'region' => 'CA',
|
||||
'postcode' => 90800,
|
||||
'country_id' => 'US',
|
||||
'email' => 'customer001@shipping.test',
|
||||
'address_type' => 'shipping',
|
||||
];
|
||||
$methodCode = 'flatrate_flatrate';
|
||||
/** @var Rate $rate */
|
||||
$rate = $objectManager->create(Rate::class);
|
||||
$rate->setCode($methodCode)
|
||||
->setPrice(5.00);
|
||||
|
||||
$address = $objectManager->create(AddressInterface::class, ['data' => $shipping]);
|
||||
$address->setShippingMethod($methodCode)
|
||||
->addShippingRate($rate)
|
||||
->setShippingAmount(5.00)
|
||||
->setBaseShippingAmount(5.00);
|
||||
|
||||
$quote->addAddress($address);
|
||||
|
||||
/** @var AddressInterface $address */
|
||||
$address = $objectManager->create(
|
||||
AddressInterface::class,
|
||||
[
|
||||
'data' => [
|
||||
'firstname' => 'Jonh',
|
||||
'lastname' => 'Doe',
|
||||
'telephone' => '0333-233-221',
|
||||
'street' => ['Third Division 1'],
|
||||
'city' => 'New York',
|
||||
'region' => 'NY',
|
||||
'postcode' => 10029,
|
||||
'country_id' => 'US',
|
||||
'email' => 'customer001@billing.test',
|
||||
'address_type' => 'billing',
|
||||
],
|
||||
]
|
||||
);
|
||||
$quote->setBillingAddress($address);
|
||||
|
||||
$quote->setIsMultiShipping(1);
|
||||
$quoteRepository->save($quote);
|
||||
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt.php');
|
||||
/** @var Product $product */
|
||||
$product = $productRepository->get('simple-with-ftp');
|
||||
|
||||
/** @var Item $item */
|
||||
$item = $objectManager->create(Item::class);
|
||||
$item->setProduct($product)
|
||||
->setPrice($product->getPrice())
|
||||
->setQty(2);
|
||||
$quote->addItem($item);
|
||||
$quoteRepository->save($quote);
|
||||
|
||||
$addressList = $quote->getAllShippingAddresses();
|
||||
$address = reset($addressList);
|
||||
$item->setQty(2);
|
||||
$address->setTotalQty(2);
|
||||
$address->addItem($item);
|
||||
$quoteRepository->save($quote);
|
||||
|
||||
$quote = $quoteFactory->create();
|
||||
$quoteResource->load($quote, 'multishipping_fpt_quote_id', 'reserved_order_id');
|
||||
/** @var PaymentInterface $payment */
|
||||
$payment = $objectManager->create(PaymentInterface::class);
|
||||
$payment->setMethod('checkmo');
|
||||
$quote->setPayment($payment);
|
||||
$quote->collectTotals();
|
||||
$quoteRepository->save($quote);
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaBuilder;
|
||||
use Magento\Quote\Api\CartRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\ObjectManager;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
|
||||
$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
|
||||
$searchCriteria = $searchCriteriaBuilder
|
||||
->addFilter('reserved_order_id', 'multishipping_fpt_quote_id')
|
||||
->create();
|
||||
/** @var CartRepositoryInterface $quoteRepository */
|
||||
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
|
||||
$quotesList = $quoteRepository->getList($searchCriteria)->getItems();
|
||||
|
||||
if (!empty($quotesList)) {
|
||||
$quote = array_pop($quotesList);
|
||||
$quoteRepository->delete($quote);
|
||||
}
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt_rollback.php');
|
||||
Reference in New Issue
Block a user