Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Before save type related data
- *
- * @param MagentoCatalogModelProduct $product
- * @return $this
- */
- public function beforeSave($product)
- {
- parent::beforeSave($product);
- $options[] = array(
- "sort_order" => 1,
- "title" => "Select Date",
- "type" => "date",
- "is_require" => 1,
- "price_type" => "fixed"
- );
- $product->unsetOptions();
- $product->setHasOptions(1);
- $product->setCanSaveCustomOptions(true);
- $product->getResource()->save($product);
- $product->setOptions(array());
- foreach ($options as $arrayOption) {
- $option = $this->_objectManager->create('MagentoCatalogModelProductOption')
- ->setProductId($product->getId())
- ->setStoreId($product->getStoreId())
- ->addData($arrayOption);
- $option->save();
- $options[] = $option;
- $product->addOption($option);
- }
- return $this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement