add one input box or select box in Admin Panel -> Product.

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
raghibkhesal2001

add one input box or select box in Admin Panel -> Product.

Post by raghibkhesal2001 » 20 Aug 2020, 08:11

I want to add one input box or select box in Admin Panel -> Product. Furthermore got this value on the following place:

Frontend -> product listing and product detail page
Admin panel Backend -> Product listing area (where we click on edit product)

I created custom extension and override the template and view of frontend.
but stuck on this part. can anyone provide me step by step guide or help? Thanks for the cooperation

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: add one input box or select box in Admin Panel -> Product.

Post by aimeos » 21 Aug 2020, 19:15

Can you post what you already have changed or overwritten?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

raghibkhesal2001

Re: add one input box or select box in Admin Panel -> Product.

Post by raghibkhesal2001 » 24 Aug 2020, 14:01

sure.


First i added "./ext/custom extension/lib/custom/src/MShop/Product/Manager/Myproject.php"

Code: Select all

public function saveItem(\Aimeos\MShop\Common\Item\Iface $item, $fetch = true)
    {
        

        $iface = '\\Aimeos\\MShop\\Product\\Item\\Iface';
        if (! ($item instanceof $iface)) {
            throw new \Aimeos\MShop\Product\Exception(sprintf('Object is not of required type "%1$s"', $iface));
        }

        if (!$item->isModified()) {
            return $item;
        }

        $context = $this->getContext();

        $dbm = $context->getDatabaseManager();
        $dbname = $this->getResourceName();
        $conn = $dbm->acquire( $dbname );

        try {
            $id = $item->getId();
            $date = date('Y-m-d H:i:s');
            if ($id === null) {
                $path = 'mshop/product/manager/standard/insert';
            } else {
                $path = 'mshop/product/manager/standard/update';
            }
            $stmt = $this->getCachedStatement($conn, $path);

            $stmt->bind(1, $item->getMLPrice());
            $stmt->bind(2, $item->getUserId());
            $stmt->bind( 3, $item->getType() );
            $stmt->bind( 4, $item->getCode() );
            $stmt->bind( 5, $item->getLabel() );
            $stmt->bind( 6, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
            $stmt->bind( 7, $item->getDateStart() );
            $stmt->bind( 8, $item->getDateEnd() );
            $stmt->bind( 9, json_encode( $item->getConfig() ) );
            $stmt->bind( 10, $date ); // mtime
            $stmt->bind( 11, $context->getEditor() );
            $stmt->bind( 12, $item->getTarget() );
            $stmt->bind( 13, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );


            if( $id !== null ) {
                $stmt->bind( 14, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
                $item->setId( $id ); //so item is no longer modified
            } else {
                $stmt->bind( 14, $date ); // ctime
            }
            $stmt->execute()->finish();
            if( $id === null && $fetch === true )
            {
                $path = 'mshop/product/manager/standard/newid';
                $item->setId( $this->newId( $conn, $path ) );
            }

            $dbm->release( $conn, $dbname );
        } catch (\Exception $e) {
            $dbm->release( $conn, $dbname );
            throw $e;
        }
        return $item;
    }
Input box is added and value is storing on the mshop_product table. but new problem is that it's only storing basic tab information. I added the value in price, category etc but its not saving

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: add one input box or select box in Admin Panel -> Product.

Post by aimeos » 25 Aug 2020, 07:46

Extend the manager by your new column this way:
https://aimeos.org/docs/Developers/Libr ... s#Easy_way

Otherwise, you need to copy the whole saveItem() method including that lines:
https://github.com/aimeos/aimeos-core/b ... #L643-L644
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

raghibkhesal2001

Re: add one input box or select box in Admin Panel -> Product.

Post by raghibkhesal2001 » 26 Aug 2020, 07:53

Thanks to guide and this issue has been resolved.

Post Reply