示例#1
0
 /**
  * Render minimal price for downloadable products
  *
  * @param \Magento\Framework\DataObject $row
  * @return string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     if ($row->getTypeId() == 'downloadable') {
         $row->setPrice($row->getPrice());
     }
     return parent::render($row);
 }
示例#2
0
 /**
  * We need reset attribute set id to attribute after related simple product was saved
  *
  * @param \Magento\Catalog\Model\ResourceModel\Product $subject
  * @param \Magento\Framework\DataObject $object
  * @return void
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeSave(\Magento\Catalog\Model\ResourceModel\Product $subject, \Magento\Framework\DataObject $object)
 {
     /** @var \Magento\Catalog\Model\Product $object */
     if ($object->getTypeId() == Configurable::TYPE_CODE) {
         $object->getTypeInstance()->getSetAttributes($object);
     }
 }
示例#3
0
 /**
  * @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
  * @param \Closure $proceed
  * @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $object
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundValidate(\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, $object)
 {
     if ($object instanceof \Magento\Catalog\Model\Product && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
         return true;
     } else {
         return $proceed($object);
     }
 }
 /**
  * @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
  * @param \Closure $proceed
  * @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $object
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundValidate(\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, $object)
 {
     if ($object instanceof \Magento\Catalog\Model\Product && $object->getTypeId() == Configurable::TYPE_CODE) {
         return true;
     } else {
         return $proceed($object);
     }
 }
 /**
  * Check whether the attribute is Applicable to the object
  *
  * @param \Magento\Framework\DataObject $object
  * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
  * @return boolean
  */
 protected function _isApplicableAttribute($object, $attribute)
 {
     $applyTo = $attribute->getApplyTo();
     return (count($applyTo) == 0 || in_array($object->getTypeId(), $applyTo)) && $attribute->isInSet($object->getAttributeSetId());
 }
示例#6
0
 /**
  * Return attribute row to prepare where statement
  *
  * @param \Magento\Framework\DataObject $entity
  * @param \Magento\Framework\DataObject $object
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return array
  */
 protected function getAttributeRow($entity, $object, $attribute)
 {
     $data = ['attribute_id' => $attribute->getId(), $entity->getEntityIdField() => $object->getData($entity->getEntityIdField())];
     if (!$this->getEntityTable()) {
         $data['entity_type_id'] = $entity->getTypeId();
     }
     return $data;
 }
示例#7
0
 /**
  * Returns whether this qty field must be inactive
  *
  * @param \Magento\Framework\DataObject $row
  * @return bool
  */
 protected function _isInactive($row)
 {
     return $this->typeConfig->isProductSet($row->getTypeId());
 }