Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. $collection = $this->productCollectionFactory->create()
  2. ->addStoreFilter($this->_storeManager->getStore()->getId())
  3. ->addAttributeToSelect(array('name'))
  4. ->addAttributeToFilter(
  5. [
  6. ['attribute' => 'name', 'like' => '%' . $searchQuery . '%'],
  7.  
  8. ])
  9. ->addFieldToFilter('type_id', ['eq' => "sellabletype"]);
  10.  
  11. foreach ($collection as $product) {
  12. $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getSmallImage())->resize(200, 200)->getUrl();
  13. $searchCollection[] = ['name' => $product->getName(), 'url' => $product->getProductUrl(), 'image' => $image_url];
  14. }
  15.  
  16. $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getSmallImage())->resize(200, 200)->getUrl();
  17.  
  18. $image_url = $this->image->init($product, 'product_page_image_small')->setImageFile($product->getImage())->resize(200, 200)->getUrl();
  19.  
  20. $imageUrl = $this->storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
  21. $productUrl = $imageUrl.'catalog/product'.$product->getImage();
  22.  
  23. $_objectManager = MagentoFrameworkAppObjectManager::getInstance();
  24. $imageHelper = $_objectManager->get('MagentoCatalogHelperImage');
  25. $product = $_objectManager->create('MagentoCatalogModelProduct')->load($product->getId());
  26. <?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