سؤال

I have created a E-commerce site by using Drupal commerce which is a clone of a shopping site created by Ektron. Now my client requirement is that if he insert a product in that site(which is created in Ektron) it will also incorporated in my site when we run import.

So I need to know how drupal_commerce insert their product details in the table.Any help regarding this wold be appreciable . If anyone need any further clarification please let me know .

Also I have some entity fields as well . Like author name , least price etc how to insert those values as well

Thanks in advance

هل كانت مفيدة؟

المحلول

Try this one ..

$values = array (
                'price' => 9271.00 ,
                'currency_code' => 'USD' ,
        );

                $cp = commerce_product_new('product');
                $cp->is_new = TRUE;
                $cp->revision_id = NULL;
                $cp->uid = 1;
                $cp->status = 1;
                $cp->created = $cp->changed = time();
                $cp->sku = '#12sku';
                $cp->title = 'New Title';
                $cp->language = 'und';

                $cp->commerce_price = array ( LANGUAGE_NONE => array ( 0 => array (
                    'amount' => $values[ 'price' ] ,
                    'currency_code' => $values[ 'currency_code' ],
                    ) ) );
                $cp->field_list_price = array ( LANGUAGE_NONE => array ( 0 => array (
                        'amount' => '300.00' ,
                        'currency_code' => $values[ 'currency_code' ],
                ) ) );

                $cp->field_isbn = array ( LANGUAGE_NONE => array ( 0 => array (
                        'value' => '#isbnn' ,
                        ) ) );
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top