PHP code example of pimcore / personalized-product-search
1. Go to this page and download the library: Download pimcore/personalized-product-search library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pimcore / personalized-product-search example snippets
namespace AppBundle\Personalization;
use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
use Pimcore\Bundle\EcommerceFrameworkBundle\OrderManager\OrderManagerInterface;
use Pimcore\Bundle\PersonalizedSearchBundle\ExtractTransformLoad\PersonalizationOrderManagerProvider;
use Pimcore\Model\DataObject\Customer;
class FactoryOrderManagerProvider implements PersonalizationOrderManagerProvider
{
function getOrderManager(): OrderManagerInterface
{
return Factory::getInstance()->getOrderManager();
}
function getCustomerClassId(): string
{
return Customer::classId();
}
}
namespace AppBundle\Personalization;
use Pimcore\Bundle\PersonalizedSearchBundle\Customer\PersonalizationAdapterCustomerIdProvider;
use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
class FactoryPersonalizationAdapterCustomerIdProvider implements PersonalizationAdapterCustomerIdProvider
{
public function getCustomerId(): int
{
return Factory::getInstance()->getEnvironment()->getCurrentUserId();
}
}
public function searchAction(SegmentAdapter $segmentAdapter, PurchaseHistoryAdapter $purchaseHistoryAdapter, RelevantProductsAdapter $relevantProductAdapter) {
// use injected adapters here (see next section)
}