Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Website.php
Go to the documentation of this file.
1 <?php
16 
18 {
24  protected function _construct()
25  {
26  $this->_init(\Magento\Catalog\Model\ResourceModel\Product\Website::class);
27  }
28 
38  {
39  try {
40  $this->_getResource()->removeProducts($websiteIds, $productIds);
41  } catch (\Exception $e) {
42  throw new \Magento\Framework\Exception\LocalizedException(
43  __('Something went wrong while removing products from the websites.')
44  );
45  }
46  return $this;
47  }
48 
58  {
59  try {
60  $this->_getResource()->addProducts($websiteIds, $productIds);
61  } catch (\Exception $e) {
62  throw new \Magento\Framework\Exception\LocalizedException(
63  __('Something went wrong while adding products to websites.')
64  );
65  }
66  return $this;
67  }
68 
76  public function getWebsites($productIds)
77  {
78  return $this->_getResource()->getWebsites($productIds);
79  }
80 }
__()
Definition: __.php:13
addProducts($websiteIds, $productIds)
Definition: Website.php:57
removeProducts($websiteIds, $productIds)
Definition: Website.php:37