Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $collection = $this->productCollectionFactory->create()
- ->addStoreFilter($this->_storeManager->getStore()->getId())
- ->addAttributeToSelect(array('name'))
- ->addAttributeToFilter(
- [
- ['attribute' => 'name', 'like' => '%' . $searchQuery . '%'],
- ])
- ->addFieldToFilter('type_id', ['eq' => "sellabletype"]);
- foreach ($collection as $product) {
- $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getSmallImage())->resize(200, 200)->getUrl();
- $searchCollection[] = ['name' => $product->getName(), 'url' => $product->getProductUrl(), 'image' => $image_url];
- }
- $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getSmallImage())->resize(200, 200)->getUrl();
- $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getImage())->resize(200, 200)->getUrl();
- $imageUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
- $productUrl = $imageUrl.'catalog/product'.$product->getImage();
- $_objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $imageHelper = $_objectManager->get('MagentoCatalogHelperImage');
- $product = $_objectManager->create('MagentoCatalogModelProduct')->load($product->getId());
- <?php $image_url= $imageHelper->init($product, 'product_thumbnail_image')->setImageFile($product->getFile())->resize(200, 200)->getUrl(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement