extcode / cart_products

CartProducts is a TYPO3 extension and provides an own data storage for simple and configurable products. Products can be offered via a list and detail view and can be purchased via cart function of the Cart extension.
7 stars 24 forks source link

Cart Product not extendable #33

Closed MarcKoester closed 5 years ago

MarcKoester commented 5 years ago

I want to update from cart 4.8 to cart 5.1 and cart_products 1.0. We have extended the Extcode\Cart\Domain\Model\Cart\Product to add a company, so we can display different terms and conditions for different companies.

The Cart Product is currently created directly without the objectManager:

https://github.com/extcode/cart_products/blob/eb0db20cb06b068c8869f91fe7fc99279ab59600/Classes/Utility/ProductUtility.php#L137-L147

Is it possible to use the objectManager to initialize the product? As it was in 4.8?

extcode commented 5 years ago

I think you can extend the product class as before and use the SignalSlot some code lines later to add your value to $cartProduct.

https://github.com/extcode/cart_products/blob/eb0db20cb06b068c8869f91fe7fc99279ab59600/Classes/Utility/ProductUtility.php#L169-L184

MarcKoester commented 5 years ago

I use the Slot to add the value:

public function createCartProductChangeNewCartProductSlot($data) {
    $productProduct = $data['productProduct'];
    $cartProduct = $data['cartProduct'];

    $cartProduct->setCompany($productProduct->getCompany());

    return [
        [
            'cartProduct' => $cartProduct
        ]
    ];
}

But this produces the error because the extbase override config.tx_extbase.objects.Extcode\Cart\Domain\Model\Cart\Product.className = Stadtwerk\CartExtension\Domain\Model\Cart\Product doesn't work anymore.

I have to create my own cartProduct Model and set everything myself to make it work again. Or am I missing soemthing?

extcode commented 5 years ago

Is the property additional of the $cartProduct an option? This field can used for own stuff.

MarcKoester commented 5 years ago

Yes that would be an option. I will use the property additional then. Thanks for your help,