Пример #1
0
 public function getRequest()
 {
     $request = new Varien_Object();
     $request->setQty($this->proxyItem->getQty());
     // grouped and downloadable products doesn't have options
     if ($this->proxyItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_GROUPED || $this->proxyItem->getProduct()->getTypeId() == Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) {
         return $request;
     }
     /** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
     $magentoProduct = Mage::getModel('M2ePro/Magento_Product')->setProduct($this->getProduct());
     $options = $this->proxyItem->getOptions();
     if (empty($options)) {
         return $request;
     }
     if ($magentoProduct->isSimpleType()) {
         $request->setOptions($options);
     } else {
         if ($magentoProduct->isBundleType()) {
             $request->setBundleOption($options);
         } else {
             if ($magentoProduct->isConfigurableType()) {
                 $request->setSuperAttribute($options);
             }
         }
     }
     return $request;
 }
Пример #2
0
 public function equals(Ess_M2ePro_Model_Order_Item_Proxy $that)
 {
     if (is_null($this->getProductId()) || is_null($that->getProductId())) {
         return false;
     }
     if ($this->getProductId() != $that->getProductId()) {
         return false;
     }
     $thisOptions = $this->getOptions();
     $thatOptions = $that->getOptions();
     $thisOptionsKeys = array_keys($thisOptions);
     $thatOptionsKeys = array_keys($thatOptions);
     $thisOptionsValues = array_values($thisOptions);
     $thatOptionsValues = array_values($thatOptions);
     if (count($thisOptions) != count($thatOptions) || count(array_diff($thisOptionsKeys, $thatOptionsKeys)) > 0 || count(array_diff($thisOptionsValues, $thatOptionsValues)) > 0) {
         return false;
     }
     // grouped products have no options, that's why we have to compare associated products
     $thisAssociatedProducts = $this->getAssociatedProducts();
     $thatAssociatedProducts = $that->getAssociatedProducts();
     if (count($thisAssociatedProducts) != count($thatAssociatedProducts) || count(array_diff($thisAssociatedProducts, $thatAssociatedProducts)) > 0) {
         return false;
     }
     return true;
 }