Esempio n. 1
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     if (is_null($this->getName())) {
         return $shoppingProduct;
     }
     $productAttribute = Mage::helper('googleshoppingapi/product')->getProductAttribute($product, $this->getAttributeId());
     $type = $this->getGcontentAttributeType($productAttribute);
     $value = $this->getProductAttributeValue($product);
     if (!is_null($value)) {
         $name = Google_Utils::camelCase($this->getName());
         $shoppingProduct->offsetSet($name, $value);
     }
     return $shoppingProduct;
 }
Esempio n. 2
0
 /**
  * Initialize this object's properties from an array.
  *
  * @param array $array Used to seed this object's properties.
  * @return void
  */
 protected function mapTypes($array)
 {
     // Hard initilise simple types, lazy load more complex ones.
     foreach ($array as $key => $val) {
         if (!property_exists($this, $this->keyType($key)) && property_exists($this, $key)) {
             $this->{$key} = $val;
             unset($array[$key]);
         } elseif (property_exists($this, $camelKey = Google_Utils::camelCase($key))) {
             // This checks if property exists as camelCase, leaving it in array as snake_case
             // in case of backwards compatibility issues.
             $this->{$camelKey} = $val;
         }
     }
     $this->modelData = $array;
 }