Extend Stock (Solved)
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Re: Extend Stock (Solved)
Hi,tenkraD wrote:Accepted i updated the post above.aimeos wrote:You should (!) only add the configuration and code you overwrite and remove the things that are the same as in the core. Especially in the configuration file (SQL statements that are the same as in the core file) and in the admin client (which should contain only the overwritten method and nothing else).
The setting for configuring your new admin client class is in generaland documentation can be found here:Code: Select all
admin/jqadm/product/stock/name = Mystandard
https://aimeos.org/docs/Configuration/C ... stock/name
Just adding code i overwrite is not working for the file
/typo3conf/ext/mhaimeos/Resources/Private/Extensions/mhaimeos/admin/jqadm/src/Admin/JQAdm/Product/Stock/Mystandard.php. Why?
Thanks admin
It should work. I overwrite client admin file and it worked.
./ext/myextension/admin/jqadm/src/Admin/JQAdm/Product/Price/Mystandard.php
Code: Select all
namespace Aimeos\Admin\JQAdm\Product\Price;
sprintf( 'price' ); // for translation
/**
* Default implementation of product price JQAdm client.
*
* @package Admin
* @subpackage JQAdm
*/
class Mystandard extends Standard
{
/**
* Creates new and updates existing items using the data array
*
* @param \Aimeos\MShop\Product\Item\Iface $item Product item object without referenced domain items
* @param string[] $data Data array
*/
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
{
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
$listTypeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' );
$listIds = (array) $this->getValue( $data, 'product.lists.id', [] );
$listItems = $manager->getItem( $item->getId(), array( 'price' ) )->getListItems( 'price', null, null, false );
$listItem = $listManager->createItem();
$listItem->setParentId( $item->getId() );
$listItem->setDomain( 'price' );
$listItem->setStatus( 1 );
$newItem = $priceManager->createItem();
$newItem->setDomain( 'product' );
foreach( $listIds as $idx => $listid )
{
if( !isset( $listItems[$listid] ) )
{
$priceItem = clone $newItem;
$litem = clone $listItem;
}
else
{
$litem = $listItems[$listid];
$priceItem = $litem->getRefItem();
}
$priceItem->setStatus( $this->getValue( $data, 'price.status/' . $idx ) );
$priceItem->setTypeId( $this->getValue( $data, 'price.typeid/' . $idx ) );
$priceItem->setCurrencyId( $this->getValue( $data, 'price.currencyid/' . $idx ) );
$priceItem->setQuantity( $this->getValue( $data, 'price.quantity/' . $idx, 1 ) );
$priceItem->setValue( $this->getValue( $data, 'price.value/' . $idx, '0.00' ) );
$priceItem->setMinimumadvertisedprice( $this->getValue( $data, 'price.minimumadvertisedprice/' . $idx, '0.00' ) );
$priceItem->setProductioncost( $this->getValue( $data, 'price.productioncost/' . $idx, '0.00' ) );
$priceItem->setIsShippingRestrictions($this->getValue($data, 'price.isshippingrestrictions/' . $idx, '0.00'));
$priceItem->setCosts( $this->getValue( $data, 'price.costs/' . $idx, '0.00' ) );
$priceItem->setRebate( $this->getValue( $data, 'price.rebate/' . $idx, '0.00' ) );
$priceItem->setTaxRate( $this->getValue( $data, 'price.taxrate/' . $idx, '0.00' ) );
$label = $priceItem->getQuantity() . ' ~ ' . $priceItem->getValue() . ' ' . $priceItem->getCurrencyId();
$priceItem->setLabel( $item->getLabel() . ' :: ' . $label );
$priceItem = $priceManager->saveItem( $priceItem );
$conf = [];
foreach( (array) $this->getValue( $data, 'config/' . $idx . '/key' ) as $num => $key )
{
$val = $this->getValue( $data, 'config/' . $idx . '/val/' . $num );
if( trim( $key ) !== '' && $val !== null ) {
$conf[$key] = trim( $val );
}
}
$litem->setConfig( $conf );
$litem->setPosition( $idx );
$litem->setRefId( $priceItem->getId() );
$litem->setTypeId( $this->getValue( $data, 'product.lists.typeid/' . $idx ) );
$litem->setDateStart( $this->getValue( $data, 'product.lists.datestart/' . $idx ) );
$litem->setDateEnd( $this->getValue( $data, 'product.lists.dateend/' . $idx ) );
$listManager->saveItem( $litem, false );
}
$rmIds = [];
$rmListIds = array_diff( array_keys( $listItems ), $listIds );
foreach( $rmListIds as $id ) {
$rmIds[] = $listItems[$id]->getRefId();
}
$listManager->deleteItems( $rmListIds );
$priceManager->deleteItems( $rmIds );
}
}
I wasted 4 years of my life doing OOP-less PHP. That's why I am facing too many problems now. Anyhow, I hope this helps you.
Thanks!
Re: Extend Stock (Solved)
Hi mohal,
thanks i knew it, the same i allready tried yesterday but i must have made an failure somewhere cause i tried it today again and its working.
Example in post post6012.html#p6012 is updated
thanks i knew it, the same i allready tried yesterday but i must have made an failure somewhere cause i tried it today again and its working.
Example in post post6012.html#p6012 is updated