ViewProduct By ProductIds
Fetch product details | getproducts detail by product id
NOTE : if you error occured you have to add class of
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
use ProductAssembler;
use ProductPresenterFactory;
You have to pass the array of product ids;
associate array pass
$results = $this->getViewedProducts($select_product_ids);
public function getViewedProducts($ids=array())
{
$productIds = $ids;
// mail('keithg@alakmalak.com','getViewedProducts',print_r($productIds,true));
$context = $this->get('prestashop.adapter.legacy.context')->getContext(); //meerank 10-6-19
if (!empty($productIds)) {
$assembler = new ProductAssembler($context);
$presenterFactory = new ProductPresenterFactory($context);
$presentationSettings = $presenterFactory->getPresentationSettings();
// mail('meerank@alakmalak.com','presentationSettings',print_r($presentationSettings,true));
$presenter = new ProductListingPresenter(
new ImageRetriever(
$context->link
),
$context->link,
new PriceFormatter(),
new ProductColorsRetriever(),
$context->getTranslator()
);
$products_for_template = array();
if (is_array($productIds)) {
foreach ($productIds as $productId) {
// mail('meerank@alakmalak.com','products_for_template1',print_r($productId,true));
if ($this->currentProductId !== $productId) {
$products_for_template[] = $presenter->present(
$presentationSettings,
$assembler->assembleProduct(array('id_product' => $productId)),
$context->language
);
}
}
}
// mail('meerank@alakmalak.com','products_for_template',print_r($products_for_template,true));
return $products_for_template;
}
return false;
}
PrestaShop - 24 Time of – Watch Store
ReplyDeleteThis new theme suitable for electronics store, watch store, jewelry store or any kind of webshop with better usability. It’s look good with colors combination. This theme can be used for any kind of online store
Ajax Cart
Multiple Language and Currency
Unlimited Banners
Mouse Hover Secondary image display
One click install (Quick Installed Files)
Products Slider (Featured, New, Special and Best Seller products) on Homepage
Cart Dropdown in Header
Grid / List product view
Product Quick View
Parallax Scrolling
SEO Friendly
Brand logo on Home page
Blogs Module
Google Web Fonts
Related Products Slider
No Core Modifications made
Optimized for Quick Load Time
Scroll To Top Button
Basic Coding Knowledge Require
Easy Installation
Full user guide documentation to help you installing and utilizing the theme
Note:
We have used free resources images in our theme. Images display in our live demo are not included with theme package.