Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. # MagentoGroupedProductModelProductTypeGrouped
  2.  
  3. public function getAssociatedProducts($product)
  4. {
  5. if (!$product->hasData($this->_keyAssociatedProducts)) {
  6. $associatedProducts = [];
  7.  
  8. $this->setSaleableStatus($product);
  9.  
  10. $collection = $this->getAssociatedProductCollection(
  11. $product
  12. )->addAttributeToSelect(
  13. ['name', 'price', 'special_price', 'special_from_date', 'special_to_date']
  14. )->addFilterByRequiredOptions()->setPositionOrder()->addStoreFilter(
  15. $this->getStoreFilter($product)
  16. )->addAttributeToFilter(
  17. 'status',
  18. ['in' => $this->getStatusFilters($product)]
  19. );
  20.  
  21. foreach ($collection as $item) {
  22. $associatedProducts[] = $item;
  23. }
  24.  
  25. $product->setData($this->_keyAssociatedProducts, $associatedProducts);
  26. }
  27. return $product->getData($this->_keyAssociatedProducts);
  28. }
  29.  
  30. Uncaught TypeError: Argument 1 passed to Vendor\Swatches\Plugin\GroupedSwatches::afterGetAssociatedProducts() must be an instance of Magento\Catalog\Model\Product, instance of Magento\GroupedProduct\Model\Product\Type\Grouped\Interceptor given
  31.  
  32. public function afterGetAssociatedProducts(MagentoCatalogModelProduct $product, $result)
  33. {
  34. $associatedProducts = array();
  35. $collection = $product->getAssociatedProductCollection(
  36. $product
  37. )->addAttributeToSelect(
  38. ['name', 'price', 'special_price', 'special_from_date', 'special_to_date', 'image', 'small_image', 'thumbnail']
  39. )->addFilterByRequiredOptions()->setPositionOrder()->addStoreFilter(
  40. $this->getStoreFilter($product)
  41. )->addAttributeToFilter(
  42. 'status',
  43. ['in' => $this->getStatusFilters($product)]
  44. );
  45.  
  46. foreach ($collection as $item) {
  47. $associatedProducts[] = $item;
  48. }
  49.  
  50. $product->setData($this->_keyAssociatedProducts, $associatedProducts);
  51.  
  52. return $result;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement