Cannot Update past 6.3.2

Hi.

I’ve built some stuff upon the community e-commerce demo. Everything went nice but now I’m stuck with Pimcore 6.3.2. Composer update does not update to any newer version of Pimcore.

Hi,
any error messages?

LG

yes…

Fatal error: Declaration of AppBundle\Ecommerce\Tracking\TrackingItemBuilder::buildProductImpressionItem(Pimcore\Bundle\EcommerceFrameworkBundle\Model\IProduct $product): Pimcore\Bundle\EcommerceFrameworkBundle\Tracking\ProductImpression must be compatible with Pimcore\Bundle\EcommerceFrameworkBundle\Tracking\TrackingItemBuilder::buildProductImpressionItem(Pimcore\Bundle\EcommerceFrameworkBundle\Model\ProductInterface $product, string $list = ‘default’) in /src/AppBundle/Ecommerce/Tracking/TrackingItemBuilder.php on line 75

Hi @tomdrops
In the version6 of pimcore Iproduct was changed to ProductInterface.Kindly update your AppBundle/Ecommerce/Tracking/TrackingItemBuilder.php file.

<?php

/**
 * Pimcore
 *
 * This source file is available under two different licenses:
 * - GNU General Public License version 3 (GPLv3)
 * - Pimcore Enterprise License (PEL)
 * Full copyright and license information is available in
 * LICENSE.md which is distributed with this source code.
 *
 * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
 * @license    http://www.pimcore.org/license     GPLv3 and PEL
 */

namespace AppBundle\Ecommerce\Tracking;

use Pimcore\Bundle\EcommerceFrameworkBundle\Model\ProductInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Tracking\ProductAction;
use Pimcore\Bundle\EcommerceFrameworkBundle\Tracking\ProductImpression;
use Pimcore\Bundle\EcommerceFrameworkBundle\Tracking\TrackingItemBuilder as BaseTrackingItemBuilder;
use Pimcore\Http\RequestHelper;

class TrackingItemBuilder extends BaseTrackingItemBuilder {

    /**
     * @var RequestHelper
     */
    private $requestHelper;

    /**
     * @var int
     */
    private $impressionPosition = 0;

    public function __construct(RequestHelper $requestHelper) {
        $this->requestHelper = $requestHelper;
    }

    public function buildProductViewItem(ProductInterface $product): ProductAction {
        $item = parent::buildProductViewItem($product);
        $item->setId($product->getOSProductNumber());

        return $item;
    }

    public function buildProductImpressionItem(ProductInterface $product, string $list = 'default'): ProductImpression {
        $this->impressionPosition++;

        $item = parent::buildProductImpressionItem($product);
        $item->setId($product->getOSProductNumber());
        $item->setList($this->getImpressionListName());
        $item->setPosition($this->impressionPosition);

        return $item;
    }

    /**
     * Get Product Impression list name.
     * i.e.: shop - list, shop - search
     *
     * @return string
     */
    private function getImpressionListName(): string {
        $request = $this->requestHelper->getCurrentRequest();

        $controller = $request->attributes->get('_controller');
        $controller = explode(':', $controller);

        return $controller[1] . ' - ' . $controller[2];
    }

}
1 Like