LoginSignup
0
2

More than 3 years have passed since last update.

【ECCUBE4】異なる管理メンバーが登録した商品を同じカートに入れられないようする。【マーケットプレイス化】

Last updated at Posted at 2020-03-28
1 / 8

目的

マーケットプレイス型ECのように、管理メンバーごとの商品管理・受注管理をできるようにカスタマイズしていきます。
主にカスタマイズする場所は下記です。
・商品管理
・受注管理


方針

メンバーに割り当てられているcreator_idを活用します。


今回すること

・メンバーが登録した商品しか管理画面商品一覧表示されるようにします。
・異なる管理メンバーが登録した商品を同じカートに入れられないようにします。


メンバーが登録した商品しか管理画面商品一覧表示されるようにします

こちらをそのまま記載します。
https://a-zumi.net/eccube4-admin-product-list-by-menber-customizer/


異なるメンバーが登録した商品は同じカートに入れられないようにする


受注を管理するため、同じメンバーの商品しかカートに入れられないようにします。

app/Customize/Service/Cart/ProductCreatorCartAllocator.php
<?php
namespace Customize\Service\Cart;

use Eccube\Entity\CartItem;

/**
 * 販売種別とcreator_idごとにカートを振り分ける CartItemAllocator
 */
class ProductCreatorCartAllocator implements \Eccube\Service\Cart\CartItemAllocator
{
    /**
     * 商品の振り分け先となるカートの識別子を決定します。
     *
     * @param CartItem $Item カート商品
     * @return string
     */
    public function allocate(CartItem $Item)
    {
        $ProductClass = $Item->getProductClass();
        if ($ProductClass && $ProductClass->getSaleType()) {
            $salesTypeId = (string) $ProductClass->getSaleType()->getId();
            return $salesTypeId . ':' . $ProductClass->getProduct()->getCreator()->getId();
        }
        throw new \InvalidArgumentException('ProductClass/SaleType not found');
    }
}
app/config/eccube/packages/cart.yaml
services:
    Eccube\Service\Cart\CartItemAllocator:
        class: Customize\Service\Cart\ProductCreatorCartAllocator
src/Eccube/Resource/locale/messages.ja.yaml
-front.cart.divide_cart: 同時購入できない商品がカートに含まれています。
+front.cart.divide_cart: 作者ごとにお買い上げが必要です。

宣伝

ハンドメイド猫グッズ専門ショップを運営しています。
ネコ好きの方、親しい間柄にネコ好きがいらっしゃる方、ぜひご覧ください。
■キャットギフト
https://cat-gift.net/

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2