マルチベンダインベントリとレンタル予約
7785 ワード
Magentoで利用可能なマルチロケーションインベントリ機能
あなたがMagento 2対他のオープンソースショッピングカートを比較している場合は、複数の場所やマルチストア機能を持っている必要がある場合、実際には比較はありません.理由は、次の最も近い競争者WooCommerceは、複数の場所やマルチストア機能の任意の並べ替えが組み込まれていないことです.WordPressはマルチサイトを持っていますが、WooCommerceのマルチストア機能についてはWooCommerceのマルチストア機能のために実際に実行可能ではありません.例えば、ストアインベントリによってストアをサポートしていないことや、ストア内の製品価格設定を設定することはできません.そして、あなたがマルチインベントリが関係する限り、「プラグインの上のプラグイン」を統合したいならば、それのために標準がないので、このコストのために存在するプラグインは余分のNDです.WooCommerce vs Magento 2 when it comes to multi store and multi inventoryの完全な破壊のために、我々の記事をチェックしてください.
マルチロケーションをレンタルで統合する方法
まず、予約表を作成する必要があります.この予約表では、開始日、終了日、注文項目ID、注文ID、およびインベントリソースを持つために最小限になります.
これがetc/dbCountスキーマでどのように見えるかです.XMLファイル:
<table name="sirental_reservationorders" resource="default" engine="innodb" comment="sirental_reservationorders">
<column xsi:type="int" name="reservationorder_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Reservationorder_id"/>
<column xsi:type="int" name="order_id" padding="10" unsigned="true" nullable="false" identity="false" default="0"/>
<column xsi:type="int" name="product_id" padding="11" unsigned="false" nullable="false" identity="false" comment="Product_id"/>
<column xsi:type="int" name="qty" padding="11" unsigned="false" nullable="false" identity="false" comment="Qty"/>
<column xsi:type="int" name="qty_cancel" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Cancelled Quantity"/>
<column xsi:type="int" name="order_item_id" padding="11" unsigned="false" nullable="true" identity="false" comment="Order_item_id"/>
<column xsi:type="datetime" name="start_date" on_update="false" nullable="true" comment="Start_date"/>
<column xsi:type="datetime" name="end_date" on_update="false" nullable="true" comment="End_date"/>
<column name="source_code" comment="Inventory Source Code" xsi:type="text"/>
</table>
その後、このテーブルのモデル、ResourceMonodel、およびCollectionを作成します.我々は、そのためのベースコードを生成するためにhttps://mage2gen.com/を推奨し、その後、それをカスタマイズします.最後に、順序が配置されると、非同期式プロセッサを作成します.async callsを作るための公式文書をチェックアウトしてください.また、定期的にレンタル注文を処理するために実行するcronとしてこれを行うことができます.cronメソッドを使用したサンプルです.
public function updateIsReserved()
{
if ($this->stock->reserveInventoryWithoutOrderInvoiced()) {
$this->searchCriteriaBuilder->addFilter('is_reserved', 0);
$criteria = $this->searchCriteriaBuilder->create();
$Orders = $this->orderRepository->getList($criteria)->getItems();
foreach ($Orders as $order) {
$this->emulation->startEnvironmentEmulation($order->getStoreId(), 'frontend');
$this->stockManagement->reserveQuoteOrOrder($order);
$order->setIsReserved(1);
$order->save();
$this->emulation->stopEnvironmentEmulation();
}
}
}
public function execute()
{
$this->updateIsReserved();
}
マルチロケーションインベントリーとレンタルインベントリによるマルチベンダの統合
これは管理者のレンタルインベントリレポートがベンダーと互換性があることを確認し、ベンダーが自分の製品を見ることができることを含んでいます.
マルチベンダー委員会支払い
ベンダーは通常、ストライプまたはPayPalを使用して支払われますが、方法はあなたがそれらを支払う方法のために変化することができます.主なメソッドは以下の通りです.
ベンダーIDに基づいてレンタル注文ノートを追加
これは、このようなオブザーバの設定を使用して行うことができます.最初にetc/eventsでファイルを作ります.このコードを使用したXML :
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_place_after">
<observer name="purchaseorder_place_order_after" instance="SalesIgniter\Purchaserentals\Observer\PurchaseRentalsComment" />
</config>
そして、モデル/オブザーバー/購入します.以下のPHPファイルを示します: public function execute(\Magento\Framework\Event\Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$orderitems = $order->getItems();
foreach($orderitems as $item) {
if ($item->getParentItem()) {
$originalBuyRequest = $item->getParentItem()->getBuyRequest();
} else {
$originalBuyRequest = $item->getBuyRequest();
}
if($originalBuyRequest->getPurchaseRentals() != null){
$originalOrder = $this->orderRepository->get($originalBuyRequest->getOriginalOrderid());
$orignalOrderInc = $originalOrder->getIncrementId();
$order->addCommentToStatusHistory('Rental Purchase for Order #: ' . $orignalOrderInc, $status = false, $isVisibleOnFront = true)->setIsCustomerNotified(false);
break;
}
}
}
レンタル用インベントリの防止
レンタルが返されるので、注文が置かれるとき、Magento 2がインベントリを差し引かないことを確認したいです.代わりにインベントリ配列を使用してインベントリを計算する必要があります開始日と終了日から構築されます.在庫控除を防ぐ方法は、ここにあります.etc/diでファイルを作ります.XMLを追加し、このコードを追加します
<type name="Magento\InventorySourceDeductionApi\Model\SourceDeductionService">
<plugin name="prevent_source_deduction_for_rental" type="SalesIgniter\Rentalinventory\Plugin\InventorySourceDeductionApi\PreventStockDeductionForRentalPlugin" sortOrder="100"/>
</type>
プラグイン/preventappendreservforforrentpluginの実際のプラグインのコードは、ここにあります.PHP public function aroundExecute(AppendReservationsInterface $subject, \Closure $proceed, array $reservations)
{
if (!$this->stockConfiguration->canSubtractQty()) {
return;
}
$reservationToAppend = [];
foreach ($reservations as $reservation) {
$stockItemConfiguration = $this->getStockItemConfiguration->execute(
$reservation->getSku(),
$reservation->getStockId()
);
// don't add inventory reservations for rental products
if(!$this->rentalHelper->isRentalTypeSimple($this->productRepository->get($reservation->getSku()))){
$reservationToAppend[] = $reservation;
}
}
if (!empty($reservationToAppend)) {
$proceed($reservationToAppend);
}
}
更なる情報
multi vendor and multi store setups with rental bookingsの詳細については、当社のWebサイトをご覧ください.
Reference
この問題について(マルチベンダインベントリとレンタル予約), 我々は、より多くの情報をここで見つけました https://dev.to/salesigniter/multi-vendor-inventory-and-rental-bookings-in-magento-2-4k0gテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol