b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / app / code / TIG / PostNL / Test / Fixtures / Quote /
Filename/home/a/home/dev2.destoffenstraat.com/app/code/TIG/PostNL/Test/Fixtures/Quote/quoteNotInStock.php
Size3.35 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified20-Dec-2022 13:13
Last accessed24-Aug-2025 07:30
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\Framework\Exception\LocalizedException;
use Magento\TestFramework\Helper\Bootstrap;

require __DIR__.'/../default_rollback.php';

Bootstrap::getInstance()->loadArea(Magento\Framework\App\Area::AREA_FRONTEND);

try {
/** @var Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
$productRepository = Bootstrap::getObjectManager()
->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
$product = $productRepository->get('simple_backorderable');
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
$product->setTypeId('simple')
->setId(2)
->setAttributeSetId(4)
->setName('Simple not in stock Product')
->setSku('simple_not_in_stock')
->setPrice(15)
->setTaxClassId(0)
->setMetaTitle('meta title')
->setMetaKeyword('meta keyword')
->setMetaDescription('meta description')
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
->setStockData(
[
'qty' => 1,
'is_in_stock' => 1,
'backorders' => 1,
'use_config_backorders' => 0
]
);

$product->save();
}

$addressData = [
'region' => 'CA',
'postcode' => '11111',
'lastname' => 'lastname',
'firstname' => 'firstname',
'street' => 'street',
'city' => 'Los Angeles',
'email' => 'admin@example.com',
'telephone' => '11111111',
'country_id' => 'US'
];

$billingAddress = Bootstrap::getObjectManager()->create(
\Magento\Quote\Model\Quote\Address::class,
['data' => $addressData]
);
$billingAddress->setAddressType('billing');

$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)->setAddressType('shipping');

/** @var \Magento\Store\Api\Data\StoreInterface $store */
$store = Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Store\Model\StoreManagerInterface::class)
->getStore();

$couldCreateQuote = false;
try {
/** @var \Magento\Quote\Model\Quote $quote */
$quote = Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
$quote->setCustomerIsGuest(true)
->setStoreId($store->getId())
->setReservedOrderId('notinstock01')
->setBillingAddress($billingAddress)
->setShippingAddress($shippingAddress)
->addProduct($product);
$quote->getPayment()->setMethod('checkmo');
$quote->setIsMultiShipping('1');
$quote->collectTotals();
$quote->save();

/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
$quoteIdMask = Bootstrap::getObjectManager()
->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
->create();
$quoteIdMask->setQuoteId($quote->getId());
$quoteIdMask->setDataChanges(true);
$quoteIdMask->save();
$couldCreateQuote = true;
}catch (LocalizedException $exception){
$couldCreateQuote = false;
}