rohitrajv5/pimcore-bundle-google-facebook-feed

在Pimcore中创建Google Feed & Facebook产品目录Feed

v2.0 2020-07-28 14:36 UTC

This package is auto-updated.

Last update: 2024-09-29 00:39:03 UTC


README

PimcoreFeedBundle 用于从您的产品类生成feed

安装

使用comporser安装

composer install rohitrajv5/pimcore-bundle-google-facebook-feed

启用PimcoreFeedBundle包

bin/console pimcore:bundle:enable PimcoreFeedBundle

安装资产

bin/console assets:install web
在您的控制器中使用以下包
use PimcoreFeedBundle\Service\Feed;
use PimcoreFeedBundle\Service\Item;
use PimcoreFeedBundle\Service\FacebookProductItem;
use PimcoreFeedBundle\Service\SimpleXMLElement;
use PimcoreFeedBundle\Service\Channel;

在您的控制器中添加以下操作

    const BASE_URL = "YOUR URL";
    const CHANNEL_TITLE = "YOUR TITLE";
    
    public function googleFeedAction(Request $request)
    {        
        $products = new DataObject\Product\Listing(); // Search listing from your product class        
        $products =  $products->load();        
        header ("Content-Type:text/xml");        
        $feed = new Feed();
        $channel = new Channel();
        $channel
            ->title(CHANNEL_TITLE)
            ->description(BASE_URL)
            ->url(BASE_URL.'/google-feed')
            ->appendTo($feed);
        $item = new Item();
        foreach($products as $product)
        {           
            /**
            You can call your own getter to map the values in array
            */
            $item
                ->title($product->getTitle())
                ->description($product->getDescription())
                ->url($product->getImageUrl())
                ->enclosure($product->getImageUrl(), 4889, 'image/jpeg')
                ->appendTo($channel);
        } 
        echo $feed;                      
    }
    public function facebookFeedAction()
    {
        header ("Content-Type:text/xml"); 
        $feed = new Feed();
        $channel = new Channel();
        $channel
            ->title(CHANNEL_TITLE)
            ->description(BASE_URL)
            ->url(BASE_URL.'/facebook-feed')
            ->appendTo($feed);

        // Product feed item
        $item = new FacebookProductItem();
        $products = new DataObject\Product\Listing();  // Search listing from your product class         
        $products =  $products->load();        
        foreach($products as $product)
        {
            /**
            You can call your own getter to map the values in array
            */
            $item
                ->id($product->getId())
                ->title($product->getTitle())
                ->description($product->getDescription())
                ->url(BASE_URL.$product->getHandle())
                ->availability('in stock') 
                ->condition('new') 
                ->googleProductCategory('Apparel & Accessories > Clothing > Underwear & Socks')
                ->imageLink($product->getImageUrl())
                ->brand($product->getBrand())             
                ->appendTo($channel);
        } 
        echo $feed; 
        
    }

记录更改!

创建以下两个文档

alt text

设置控制器与操作。分别对应两个文档

alt text

保存并发布

完成!

导航到Google & Facebook Feed网址!

Google: http://[YOUR_APPLICATION_URL]/google-feed
Facebook: http://[YOUR_APPLICATION_URL]/facebook-feed

Facebook Feed:!

alt text

Google Feed:!

alt text

特性!

  • 插件将生成Facebook & Google Feed
  • 公共url将直接由Google & Facebook访问

许可证

GPL-3.0+