Composite.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogInventory\Block\Stockqty;
  7. use Magento\Catalog\Model\Product;
  8. /**
  9. * Product stock qty block for abstract composite product
  10. */
  11. abstract class Composite extends DefaultStockqty
  12. {
  13. /**
  14. * Child products cache
  15. *
  16. * @var Product[]
  17. */
  18. private $_childProducts;
  19. /**
  20. * Retrieve child products
  21. *
  22. * @return Product[]
  23. */
  24. abstract protected function _getChildProducts();
  25. /**
  26. * Retrieve child products (using cache)
  27. *
  28. * @return Product[]
  29. */
  30. public function getChildProducts()
  31. {
  32. if ($this->_childProducts === null) {
  33. $this->_childProducts = $this->_getChildProducts();
  34. }
  35. return $this->_childProducts;
  36. }
  37. /**
  38. * Retrieve id of details table placeholder in template
  39. *
  40. * @return string
  41. */
  42. public function getDetailsPlaceholderId()
  43. {
  44. return $this->getPlaceholderId() . '-details';
  45. }
  46. }