Export Methods

This four methods are probably the most important functions to implement in your shop system. These methods are used to setup a “copy” of your system in Shopgate. All data will be permanently updated within the Shopgate system by the import process.

get_categories

This allows you to export item categories from your shop system to the Shopgate Categories XML Format.

Plugin Example

createCategories
    <?
		class MyPlugin extends ShopgatePlugin
    {
        ......

        protected function createCategories($limit = null, $offset = null, array $uids = array ())
        {
            /**
             * init category model
             */
            $categoryItem = new Shopgate_Model_Catalog_Category();

            $categoryItem->setUid(10);									        /** required */
            $categoryItem->setName('Example Category');						    /** required */
            $categoryItem->setParentUid(4);								        /** optional */
            $categoryItem->setIsActive(true);								    /** optional | default false */
            $categoryItem->setDeeplink('http://example-shop/category/id/10');   /** optional */
            $categoryItem->setIsAnchor(true);								    /** optional | default false */
            $categoryItem->setSortOrder(10);								    /** optional */

            /**
             * init image model
             */
            $imageItem = new Shopgate_Model_Media_Image();

            $imageItem->setUid(10);											        /** required */
            $imageItem->setSortOrder(10);									        /** optional */
            $imageItem->setAlt('Example Alt 1');								    /** optional */
            $imageItem->setUrl('http://example-shop/category/id/10/image/id/10');	/** optional */
            $imageItem->setTitle('Example Title 1');								/** required */

            /**
             * add to category model
             */
            $categoryItem->setImage($imageItem);
            $this->addCategoryModel($categoryItem);
        }

get_items

This item allows you to export item information from your shop system to the Shopgate Items XML Format.

Plugin Example

createItems
<?
    class MyPlugin extends ShopgatePlugin
    {

        protected function createItems($limit = null, $offset = null, array $uids = array ())
	    {

            /**
             * init product model
             */
            $productItem = new Shopgate_Model_Catalog_Product();

            $productItem->setUid(10);
            $productItem->setName('Example Product 1');
            $productItem->setTaxPercent(19);
            $productItem->setTaxClass('19% MwSt DE');
            $productItem->setCurrency('EUR');
            $productItem->setDescription('Example Description');
            $productItem->setDeeplink('http://example-shop/product/id/10/');
            $productItem->setPromotionSortOrder(10);
            $productItem->setInternalOrderInfo('Example Order Info');
            $productItem->setAgeRating(18);
            $productItem->setWeight(10);
            $productItem->setWeightUnit(Shopgate_Model_Catalog_Product::DEFAULT_WEIGHT_UNIT_GRAMM);

            ...........

            /**
             * add item
             */
            $this->addItemModel($productItem);

Plugin Example Price

Price model
<?
            /**
             * init price model
             */
            $priceItem = new Shopgate_Model_Catalog_Price();
            $priceItem->setPrice(22.99);
            $priceItem->setCost(12.99);
            $priceItem->setMinimumOrderAmount(1);
            $priceItem->setMsrp(18.99);
            $priceItem->setSalePrice(21.99);

            /**
             * init tier price (optional)
             */
            $tierPriceItem = new Shopgate_Model_Catalog_TierPrice();
            $tierPriceItem->setAggregateChildren(true);
            $tierPriceItem->setCustomerGroupUid(1);
            $tierPriceItem->setFromQuantity(10);
            $tierPriceItem->setToQuantity(20);
            $tierPriceItem->setReduction(5.99);
            $tierPriceItem->setReductionType(Shopgate_Model_Catalog_TierPrice::DEFAULT_TIER_PRICE_TYPE_FIXED);

            /**
             * add to price model
             */
            $priceItem->addTierPriceGroup($tierPriceItem);

            /**
             * init tier price (optional)
             */
            $tierPriceItem = new Shopgate_Model_Catalog_TierPrice();
            $tierPriceItem->setCustomerGroupUid(1);
            $tierPriceItem->setFromQuantity(20);
            $tierPriceItem->setToQuantity(30);
            $tierPriceItem->setReduction(8.99);
            $tierPriceItem->setReductionType(Shopgate_Model_Catalog_TierPrice::DEFAULT_TIER_PRICE_TYPE_FIXED);

            /**
             * add to price model
             */
            $priceItem->addTierPriceGroup($tierPriceItem);

            /**
             * add to product model
             */
            $productItem->setPrice($priceItem);
            ........
            $this->addItemModel($productItem);

Plugin Example Images

Image model
<?
            /**
             * init image model
             */
            $imageItem = new Shopgate_Model_Media_Image();
            $imageItem->setUid(10);
            $imageItem->setIsCover(true);
            $imageItem->setSortOrder(10);
            $imageItem->setAlt('Example Alt 1');
            $imageItem->setTitle('Example Title 1');
            $imageItem->setUrl('http://example-shop/product/id/10/image/id/10');

            /**
             * add to product model
             */
            $productItem->addImage($imageItem);

            /**
             * init image model
             */
            $imageItem = new Shopgate_Model_Media_Image();
            $imageItem->setUid(20);
            $imageItem->setIsCover(false);
            $imageItem->setSortOrder(20);
            $imageItem->setAlt('Example Alt 2');
            $imageItem->setTitle('Example Title 1');
            $imageItem->setUrl('http://example-shop/product/id/10/image/id/20');

            /**
             * add to product model
             */
            $productItem->addImage($imageItem);

Plugin Example Categories

Category path model
<?
            /**
             * init category path model
             */
            $categoryPathItem = new Shopgate_Model_Catalog_CategoryPath();
            $categoryPathItem->setUid(10);
            $categoryPathItem->setSortOrder(10);
            $categoryPathItem->setDeeplink('http://example-shop/category/id/10');
            $categoryPathItem->addItem(0, 'Home');
            $categoryPathItem->addItem(1, 'Specials');

            /**
             * add to product item
             */
            $productItem->addCategoryPath($categoryPathItem);

            /**
             * init category path model
             */
            $categoryPathItem = new Shopgate_Model_Catalog_CategoryPath();
            $categoryPathItem->setUid(20);
            $categoryPathItem->setSortOrder(20);
            $categoryPathItem->setDeeplink('http://example-shop/category/id/20');
            $categoryPathItem->addItem(0, 'Home');
            $categoryPathItem->addItem(1, 'Example 1');
            $categoryPathItem->addItem(2, 'Example 2');

            /**
             * add to product item
             */
            $productItem->addCategoryPath($categoryPathItem);

Plugin Example Shipping

Shipping model
<?
            /**
             * init shipping model
             */
            $shippingItem = new Shopgate_Model_Catalog_Shipping();
            $shippingItem->setIsFree(false);
            $shippingItem->setAdditionalCostsPerUnit(1.99);
            $shippingItem->setCostsPerOrder(0.99);

            /**
             * add to product model
             */
            $productItem->setShipping($shippingItem);

Plugin Example Manufacturer

Manufacturer model
<?
            /**
             * init manufacturer model
             */
            $manufacturerItem = new Shopgate_Model_Catalog_Manufacturer();
            $manufacturerItem->setUid(10);
            $manufacturerItem->setTitle('Shopgate');
            $manufacturerItem->setItemNumber('sg');

            /**
             * add to product
             */
            $productItem->setManufacturer($manufacturerItem);

Plugin Example Visibility

Visibility model
<?
            /**
             * init visibility model
             */
            $visibilityItem = new Shopgate_Model_Catalog_Visibility();
            $visibilityItem->setLevel(Shopgate_Model_Catalog_Visibility::DEFAULT_VISIBILITY_CATALOG_AND_SEARCH);
            $visibilityItem->setMarketplace(false);

            /**
             * add to product model
             */
            $productItem->setVisibility($visibilityItem);

Plugin Example Properties

Property model
<?
            /**
             * init property model
             */
            $propertyItem = new Shopgate_Model_Catalog_Property();
            $propertyItem->setUid(10);
            $propertyItem->setLabel('Example Property 1');
            $propertyItem->setValue('example value 1');

            /**
             * add to product model
             */
            $productItem->addProperty($propertyItem);

            /**
             * init property model
             */
            $propertyItem = new Shopgate_Model_Catalog_Property();
            $propertyItem->setUid(20);
            $propertyItem->setLabel('Example Property 2');
            $propertyItem->setValue('example value 2');

            /**
             * add to product model
             */
            $productItem->addProperty($propertyItem);

Plugin Example Stock

Stock model
<?
            /**
             * init stock model
             */
            $stockItem = new Shopgate_Model_Catalog_Stock();
            $stockItem->setStockQuantity(100);
            $stockItem->setAvailabilityText('in stock');
            $stockItem->setBackorders(true);
            $stockItem->setIsSaleable(true);
            $stockItem->setUseStock(true);
            $stockItem->setMinimumOrderQuantity(1);
            $stockItem->setMaximumOrderQuantity(10);

            /**
             * add to product
             */
            $productItem->setStock($stockItem);

Plugin Example Identifiers

Identifier model
<?
            /**
             * init identifier model
             */
            $identifierItem = new Shopgate_Model_Catalog_Identifier();
            $identifierItem->setUid(10);
            $identifierItem->setType('EAN');
            $identifierItem->setValue('00000001');

            /**
             * add to product
             */
            $productItem->addIdentifier($identifierItem);

            /**
             * init identifier model
             */
            $identifierItem = new Shopgate_Model_Catalog_Identifier();
            $identifierItem->setUid(20);
            $identifierItem->setType('EXAMPLE');
            $identifierItem->setValue('e_2004_001');

            /**
             * add to product
             */
            $productItem->addIdentifier($identifierItem);

Plugin Example Tags

Tag model
<?
            /**
             * init tag model
             */
            $tagItem = new Shopgate_Model_Catalog_Tag();
            $tagItem->setUid(10);
            $tagItem->setValue('Example Tag 1');

            /**
             * add to product model
             */
            $productItem->addTag($tagItem);

            /**
             * init tag model
             */
            $tagItem = new Shopgate_Model_Catalog_Tag();
            $tagItem->setUid(20);
            $tagItem->setValue('Example Tag 2');

            /**
             * add to product model
             */
            $productItem->addTag($tagItem);

Plugin Example Relations

Relation model
<?
            /**
             * init relation model
             */
            $relationItem = new Shopgate_Model_Catalog_Relation();
            $relationItem->setType(Shopgate_Model_Catalog_Relation::DEFAULT_RELATION_TYPE_CROSSSELL);
            $relationItem->addValue(100);
            $relationItem->addValue(102);

            /**
             * add to product
             */
            $productItem->addRelation($relationItem);

            /**
             * init relation model
             */
            $relationItem = new Shopgate_Model_Catalog_Relation();
            $relationItem->setType(Shopgate_Model_Catalog_Relation::DEFAULT_RELATION_TYPE_CUSTOM);
            $relationItem->setLabel('Custom Relation');
            $relationItem->addValue(105);
            $relationItem->addValue(109);

            /**
             * add to product
             */
            $productItem->addRelation($relationItem);

Plugin Example attributes Group

Attribute group model
<?
            /**
             * init attribute group model
             */
            $attributeGroupItem = new Shopgate_Model_Catalog_AttributeGroup();
            $attributeGroupItem->setUid('10');
            $attributeGroupItem->setLabel('Color');

            /**
             * add to product model
             */
            $productItem->addAttributeGroup($attributeGroupItem);

            /**
             * init attribute group model
             */
            $attributeGroupItem = new Shopgate_Model_Catalog_AttributeGroup();
            $attributeGroupItem->setUid('20');
            $attributeGroupItem->setLabel('Size');

            /**
             * add to product model
             */
            $productItem->addAttributeGroup($attributeGroupItem);

Plugin Example Inputs

Inputs model
<?
            /**
             * init inputs model
             */
            $inputItem = new Shopgate_Model_Catalog_Input();
            $inputItem->setUid(10);
            $inputItem->setLabel('PDF upload');
            $inputItem->setInfoText('Please select a pdf file');
            $inputItem->setType(Shopgate_Model_Catalog_Input::DEFAULT_INPUT_TYPE_FILE);

            /**
             * validation
             * init validation model
             */
            $validationItem = new Shopgate_Model_Catalog_Validation();
            $validationItem->setValidationType(Shopgate_Model_Catalog_Validation::DEFAULT_VALIDATION_FILE_PDF);

            /**
             * add to input item
             */
            $inputItem->setValidation($validationItem);

            /**
             * add to product
             */
            $productItem->addInput($inputItem);

            /**
             * init inputs model
             */
            $inputItem = new Shopgate_Model_Catalog_Input();
            $inputItem->setUid(20);
            $inputItem->setLabel('Select some Item');
            $inputItem->setInfoText('Please select');
            $inputItem->setType(Shopgate_Model_Catalog_Input::DEFAULT_INPUT_TYPE_SELECT);

            /**
             * options
             *
             * init option model
             */
            $optionModel = new Shopgate_Model_Catalog_Option();
            $optionModel->setUid(10);
            $optionModel->setLabel('Item 1');
            $optionModel->setValue(1);
            $optionModel->setAdditionalPrice(1.99);

            /**
             * add to input model
             */
            $inputItem->addOption($optionModel);

            /**
             * init option model
             */
            $optionModel = new Shopgate_Model_Catalog_Option();
            $optionModel->setUid(20);
            $optionModel->setLabel('Item 2');
            $optionModel->setValue(2);
            $optionModel->setAdditionalPrice(1.49);

            /**
             * add to input model
             */
            $inputItem->addOption($optionModel);

            /**
             * validation
             * init validation model
             */
            $validationItem = new Shopgate_Model_Catalog_Validation();
            $validationItem->setValidationType(Shopgate_Model_Catalog_Validation::DEFAULT_VALIDATION_VARIABLE_INT);

            /**
             * add to input item
             */
            $inputItem->setValidation($validationItem);

            /**
             * add to product
             */
            $productItem->addInput($inputItem);

            /**
             * init inputs model
             */
            $inputItem = new Shopgate_Model_Catalog_Input();
            $inputItem->setUid(20);
            $inputItem->setLabel('Insert som text');
            $inputItem->setInfoText('only numbers allowed');
            $inputItem->setType(Shopgate_Model_Catalog_Input::DEFAULT_INPUT_TYPE_TEXT);

            /**
             * init validation model
             */
            $validationItem = new Shopgate_Model_Catalog_Validation();
            $validationItem->setValidationType(Shopgate_Model_Catalog_Validation::DEFAULT_VALIDATION_TYPE_REGEX);
            $validationItem->setValue('^[0-9]+$');

            /**
             * add to input item
             */
            $inputItem->setValidation($validationItem);

            /**
             * add to product
             */
            $productItem->addInput($inputItem);

Plugin Example Children

Children model
<?
            /**
             * init children model (product model)
             */
            $childItem = new Shopgate_Model_Catalog_Product();
            $childItem->setIsChild(true);

            /**
             * attributes
             * init attribute model
             */
            $attributeItem = new Shopgate_Model_Catalog_Attribute();
            $attributeItem->setUid(10);
            $attributeItem->setGroupUid(10);
            $attributeItem->setLabel('red');

            /**
             * add to child item
             */
            $childItem->addAttribute($attributeItem);

            /**
             * init attribute model
             */
            $attributeItem = new Shopgate_Model_Catalog_Attribute();
            $attributeItem->setUid(10);
            $attributeItem->setGroupUid(20);
            $attributeItem->setLabel('XXL');

            /**
             * price
             * init price model
             */
            $priceItem = new Shopgate_Model_Catalog_Price();

            $priceItem->setPrice(18.88);

            /**
             * add to child product
             */
            $childItem->setPrice($priceItem);

            /**
             * add to child item
             */
            $childItem->addAttribute($attributeItem);

            /**
             * you can extend / rewrite every property from the parent product
             * uid example
             */
            $childItem->setUid('10_1');

            /**
             * example name
             */
            $childItem->setName('Example Product 1 (Child)');

            /**
             * example identifier
             * init identifier model
             */
            $identifierItem = new Shopgate_Model_Catalog_Identifier();

            /**
             * uid from the parent identifier id
             */
            $identifierItem->setUid(10);
            $identifierItem->setValue('00000002');

            /**
             * add to the child product
             */
            $childItem->addIdentifier($identifierItem);
            $productItem->addChild($childItem);

get_reviews

This allows you to export reviews from your shop system to the Shopgate Categories XML Format.

Plugin Example

createReviews
<?
    class MyPlugin extends ShopgatePlugin
    {
        ......

        protected function createReviews($limit = null, $offset = null, array $uids = array ())
        {
            /**
             * init review model
             */
            $reviewItem = new Shopgate_Model_Review();

            $reviewItem->setUid(10);									                        /** required */
            $reviewItem->setItemUid(312);	                            					    /** required */
            $reviewItem->setScore(6);								                            /** required */
            $reviewItem->setReviewerName('John Doe');								            /** required */
            $reviewItem->setDate('2007-08-25');                                                 /** optional */
            $reviewItem->setTitle('Great Product');								                /** optional */
            $reviewItem->setText('I would highly recommend to buy this product because...');    /** optional */

            $this->addReviewModel($reviewItem);
        }