Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2011
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.90 KB | None | 0 0
  1.              
  2.               $product->setName($_product['name']);
  3.         //    $product->setDescription($_product['description']);
  4.         //    $product->setShortDescription($_product['short_description']);
  5.               $product->setPrice($_product['price']);
  6.               $product->setTypeId('simple');
  7.               $product->setAttributeSetId(4); // need to look this up 4 default
  8.               $product->setCategoryIds("0,".$group); // need to look these up
  9.               $product->setWeight($_product['weight']);
  10.               $product->setTaxClassId(2); // taxable goods
  11.               $product->setVisibility(4); // catalog, search
  12.               $product->setStatus(1); // enabled
  13.               $product->setTariefGroep($tariefcode);
  14.               $product->setWeekPrijs($_product['weekprijs']);
  15.               $product->setHuurdagen($_product['huurdagen']);
  16.               $product->setUrlKey($_product['name']);
  17.               $product->setTarieven($_product['tarieven']);
  18.               $product->setNextday($_product['nextday']);
  19.               $product->setMinSaleQty(1);
  20.               $product->setData('bijgeleverd', $bijgeleverd);
  21.  
  22.  
  23.               if ($group == 112) { #disabled_products in website (Parent group 100 in insphire)
  24.                $product->setStatus(2);
  25.               }
  26.              
  27.               if ($_product['group'] == 'VERK') {
  28.                 $product->setVerkoop(1);
  29.                
  30.                 // Stock beheren
  31.                 $_product['is_in_stock'] = (int)($_product['qty'] > 0); // Moet uit import
  32.               } else {
  33.                 $product->setVerkoop(0);
  34.                
  35.                 $_product['qty']          = 1;
  36.                 $_product['is_in_stock']  = 1;
  37.                 $_product['min_sale_qty'] = 1;
  38.                
  39.               }
  40.              
  41.               if ($newProduct == true) {
  42.            
  43.                 // update stock data using new data
  44.                 $stockData['qty']         = 1;
  45.                 $stockData['is_in_stock'] = 1;
  46.                 $stockData['min_sale_qty'] = 1;
  47.                
  48.                 // then set product's stock data to update
  49.                 $product->setStockData($stockData);
  50.                 unset($stockData);
  51.                
  52.               } else { /* is geen nieuw product .. updaten .. */
  53.                
  54.                   $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($exists->getId());
  55.                  
  56.                   if ($stockItem) {
  57.                       $stockItem->setData('qty', $_product['qty']);
  58.                       $stockItem->setData('is_in_stock', $_product['is_in_stock']);
  59.                       $stockItem->setData('min_sale_qty', 1);
  60.                      
  61.                       if ($_product['group'] == 'VERK') {
  62.                         $stockItem->setData('manage_stock', 1);
  63.                         $stockItem->setData('use_config_manage_stock', 0); 
  64.                       }
  65.                      $stockItem->save();
  66.                   }
  67.                  
  68.               }    
  69.              
  70.               // assign product to the default website
  71.               $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
  72.              
  73.                    
  74.               $id = $product->save();
  75.                          
  76.               if ($newProduct == true) {
  77.                 $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
  78.                 if ($stockItem) {
  79.                   if ($_product['group'] == 'VERK') {
  80.                     $stockItem->setData('manage_stock', 1);
  81.                     $stockItem->setData('use_config_manage_stock', 0); 
  82.                   }
  83.                   $stockItem->save();
  84.                 }
  85.               }
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement