Extending MShop Price
Posted: 06 Jun 2020, 07:13
Hi, I am having a problem in extending this file-:
https://github.com/aimeos/aimeos-core/b ... d.php#L415
To extend this I have done the following -:
1. I have created a file named Ebdaa.php in the dir ebdaa/lib/custom/src/MShop/Price/Item/Ebdaa.php
2.I have added the following code in the above dir path file name Ebdaa.php
<?php
namespace Aimeos\MShop\Price\Item;
class Ebdaa extends Standard
{
**
* Add the given price to the current one.
*
* @param \Aimeos\MShop\Price\Item\Iface $item Price item which should be added
* @param float $quantity Number of times the Price should be added
* @return \Aimeos\MShop\Price\Item\Iface Price item for chaining method calls
*/
public function addItem( \Aimeos\MShop\Price\Item\Iface $item, float $quantity = 1 ) : \Aimeos\MShop\Price\Item\Iface
{
dd('here');
if( $item->getCurrencyId() != $this->getCurrencyId() )
{
$msg = 'Price can not be added. Currency ID "%1$s" of price item and currently used currency ID "%2$s" does not match.';
throw new \Aimeos\MShop\Price\Exception( sprintf( $msg, $item->getCurrencyId(), $this->getCurrencyId() ) );
}
if( $this === $item ) { $item = clone $item; }
$taxValue = $this->getTaxValue(); // use initial value before it gets reset
$this->setQuantity( 1 );
$this->setValue( $this->getValue() + $item->getValue() * $quantity );
$this->setCosts( $this->getCosts() + $item->getCosts() );
$this->setRebate( $this->getRebate() + $item->getRebate() * $quantity );
$this->setTaxValue( $taxValue + $item->getTaxValue() * $quantity );
return $this;
}
}
3. In the config/shop.php I have added the following lines -:
'mshop' => [
'locale' => [
'manager' => [
'standard' => [
'sitelevel' => 3
]
]
],
'order' => [
'manager' => [
'base' => [
'name' => 'Ebdaa'
]
]
],
'price' => [
'item' => [
'name' => 'Ebdaa'
]
]
],
This is not getting extended. Please assist. Thank you in advance.
https://github.com/aimeos/aimeos-core/b ... d.php#L415
To extend this I have done the following -:
1. I have created a file named Ebdaa.php in the dir ebdaa/lib/custom/src/MShop/Price/Item/Ebdaa.php
2.I have added the following code in the above dir path file name Ebdaa.php
<?php
namespace Aimeos\MShop\Price\Item;
class Ebdaa extends Standard
{
**
* Add the given price to the current one.
*
* @param \Aimeos\MShop\Price\Item\Iface $item Price item which should be added
* @param float $quantity Number of times the Price should be added
* @return \Aimeos\MShop\Price\Item\Iface Price item for chaining method calls
*/
public function addItem( \Aimeos\MShop\Price\Item\Iface $item, float $quantity = 1 ) : \Aimeos\MShop\Price\Item\Iface
{
dd('here');
if( $item->getCurrencyId() != $this->getCurrencyId() )
{
$msg = 'Price can not be added. Currency ID "%1$s" of price item and currently used currency ID "%2$s" does not match.';
throw new \Aimeos\MShop\Price\Exception( sprintf( $msg, $item->getCurrencyId(), $this->getCurrencyId() ) );
}
if( $this === $item ) { $item = clone $item; }
$taxValue = $this->getTaxValue(); // use initial value before it gets reset
$this->setQuantity( 1 );
$this->setValue( $this->getValue() + $item->getValue() * $quantity );
$this->setCosts( $this->getCosts() + $item->getCosts() );
$this->setRebate( $this->getRebate() + $item->getRebate() * $quantity );
$this->setTaxValue( $taxValue + $item->getTaxValue() * $quantity );
return $this;
}
}
3. In the config/shop.php I have added the following lines -:
'mshop' => [
'locale' => [
'manager' => [
'standard' => [
'sitelevel' => 3
]
]
],
'order' => [
'manager' => [
'base' => [
'name' => 'Ebdaa'
]
]
],
'price' => [
'item' => [
'name' => 'Ebdaa'
]
]
],
This is not getting extended. Please assist. Thank you in advance.