public function create($productCategory, $product)
    {
        if (!$product instanceof Product) {
            $product = $this->api('subbly.product')->find($product);
        }

        // if (is_array($productCategory)) {
        //     $productCategory = new ProductCategory($productCategory);
        // }

        // if ($productCategory instanceof ProductCategory)
        if ($product instanceof Product) {
            if ($this->fireEvent('creating', array($productCategory, $product)) === false) {
                return false;
            }

            // $productCategory->product()->associate($product);
            $product->categories()->sync($productCategory);

            // $productCategory->setCaller($this);
            // $productCategory->save();

            $this->fireEvent('created', array($productCategory, $product));

            // $productCategory = $this->find($productCategory->uid);

            return true;
        }

        throw new Exception(sprintf(Exception::CANT_CREATE_MODEL,
            $this->modelClass,
            $this->name()
        ));
    }
public function create($productCategory, $product)
    {
        if (!$product instanceof Product) {
            $product = $this->api('subbly.product')->find($product);
        }

        // if (is_array($productCategory)) {
        //     $productCategory = new ProductCategory($productCategory);
        // }

        // if ($productCategory instanceof ProductCategory)
        if ($product instanceof Product) {
            if ($this->fireEvent('creating', array($productCategory, $product)) === false) {
                return false;
            }

            // $productCategory->product()->associate($product);
            $product->categories()->sync($productCategory);

            // $productCategory->setCaller($this);
            // $productCategory->save();

            $this->fireEvent('created', array($productCategory, $product));

            // $productCategory = $this->find($productCategory->uid);

            return true;
        }

        throw new Exception(sprintf(Exception::CANT_CREATE_MODEL,
            $this->modelClass,
            $this->name()
        ));
    }
public function create ( $ productCategory , $ product ) { if ( ! $ product instanceof Product ) { $ product = $ this -> api ( 'subbly.product' ) -> find ( $ product ) ; } // if (is_array($productCategory)) { //     $productCategory = new ProductCategory($productCategory); // } // if ($productCategory instanceof ProductCategory) if ( $ product instanceof Product ) { if ( $ this -> fireEvent ( 'creating' , array ( $ productCategory , $ product ) ) === false ) { return false ; } // $productCategory->product()->associate($product); $ product -> categories ( ) -> sync ( $ productCategory ) ; // $productCategory->setCaller($this); // $productCategory->save(); $ this -> fireEvent ( 'created' , array ( $ productCategory , $ product ) ) ; // $productCategory = $this->find($productCategory->uid); return true ; } throw new Exception ( sprintf ( Exception :: CANT_CREATE_MODEL , $ this -> modelClass , $ this -> name ( ) ) ) ; }
Create a new ProductCategory.

@example
$product = Subbly\Model\ProductCategory;
Subbly::api('subbly.product_category')->create($productCategory);

Subbly::api('subbly.product_category')->create(array(
'firstname' => 'Jon',
'lastname'  => 'Snow',
));

@param \Subbly\Model\ProductCategory|array $productCategory
@param \Subbly\Model\Product|null          $product

@return \Subbly\Model\ProductCategory

@throws \Subbly\Api\Service\Exception

@api
Create a new ProductCategory .