Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
66766da9
Commit
66766da9
authored
Mar 03, 2023
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加fackbook feed生成脚本
parent
68b191c1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
308 additions
and
0 deletions
+308
-0
.gitignore
+1
-0
app/code/Joshine/facebookfeed/Console/Command/FacebookFeed.php
+246
-0
app/code/Joshine/facebookfeed/etc/di.xml
+10
-0
app/code/Joshine/facebookfeed/etc/module.xml
+8
-0
app/code/Joshine/facebookfeed/registration.php
+6
-0
vendor/magento/module-aws-s3-page-builder/Test/Mftf/Suite/RemoteStorageAwsS3EnabledPageBuilderSuite.xml
+37
-0
No files found.
.gitignore
View file @
66766da9
...
...
@@ -15,3 +15,4 @@ var
.idea
/.php_cs.cache
/app/design/frontend/Joshine/breeze/Magento_Theme/templates/root.phtml
/pub/feed
app/code/Joshine/facebookfeed/Console/Command/FacebookFeed.php
0 → 100644
View file @
66766da9
<?php
namespace
Joshine\FacebookFeed\Console\Command
;
use
Magento\Framework\App\State
;
use
Magento\Store\Model\Store
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Magento\Framework\Api\SearchCriteriaBuilder
;
use
Magento\Catalog\Model\ProductRepository
;
use
Magento\Framework\Filesystem
;
use
Magento\Framework\App\Filesystem\DirectoryList
;
use
Magento\Catalog\Helper\Image
as
ImageFactory
;
use
Magento\CatalogInventory\Model\Stock\StockItemRepository
;
use
Magento\ConfigurableProduct\Api\LinkManagementInterface
;
use
Magento\Store\Model\StoreManagerInterface
;
/**
* Class SomeCommand
*/
class
FacebookFeed
extends
Command
{
/* @var ProductRepository */
private
$productRepository
;
/* var SearchCriteriaBuilder */
private
$searchCriteriaBuilder
;
/* var DirectoryList */
private
$directoryList
;
/* var Filesystem */
private
$filesystem
;
/* @var ImageFactory */
protected
$imageHelperFactory
;
/* @var StockItemRepository */
protected
$stockItemRepository
;
/* @var LinkManagementInterface */
protected
$linkManagement
;
/* @var StoreManagerInterface */
protected
$storeManager
;
private
$columns
=
array
(
'id'
,
'title'
,
'description'
,
'availability'
,
'condition'
,
'price'
,
'link'
,
'image_link'
,
'brand'
,
'google_product_category'
,
'fb_product_category'
,
'quantity_to_sell_on_facebook'
,
'sale_price'
,
'sale_price_effective_date'
,
'item_group_id'
,
'gender'
,
'color'
,
'size'
,
'age_group'
,
'material'
,
'pattern'
,
'shipping'
,
'shipping_weight'
,
'style[0]'
,
);
/**
* @inheritDoc
*/
protected
function
configure
()
{
$this
->
setName
(
'catalog:facebookfeed'
);
$this
->
setDescription
(
'Generates a product feed for facebook'
);
parent
::
configure
();
}
/**
* FacebookFeed constructor.
* @param State $state
* @param ProductRepository $productRepository
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param DirectoryList $directoryList
* @param Filesystem $filesystem
* @param ImageFactory $imageHelperFactory
* @param StockItemRepository $stockItemRepository
* @param LinkManagementInterface $linkManagement
*/
public
function
__construct
(
State
$state
,
ProductRepository
$productRepository
,
SearchCriteriaBuilder
$searchCriteriaBuilder
,
DirectoryList
$directoryList
,
Filesystem
$filesystem
,
ImageFactory
$imageHelperFactory
,
StockItemRepository
$stockItemRepository
,
LinkManagementInterface
$linkManagement
,
StoreManagerInterface
$storeManager
)
{
$this
->
state
=
$state
;
$this
->
productRepository
=
$productRepository
;
$this
->
searchCriteriaBuilder
=
$searchCriteriaBuilder
;
$this
->
directoryList
=
$directoryList
;
$this
->
filesystem
=
$filesystem
;
$this
->
imageHelperFactory
=
$imageHelperFactory
;
$this
->
stockItemRepository
=
$stockItemRepository
;
$this
->
linkManagement
=
$linkManagement
;
$this
->
storeManager
=
$storeManager
;
parent
::
__construct
();
}
/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return null|int
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$this
->
state
->
setAreaCode
(
\Magento\Framework\App\Area
::
AREA_ADMINHTML
);
$criteria
=
$this
->
searchCriteriaBuilder
->
addFilter
(
'status'
,
'1'
,
'eq'
)
->
addFilter
(
'type_id'
,
'configurable'
,
'eq'
)
->
addFilter
(
'visibility'
,
'4'
,
'eq'
)
->
create
();
$products
=
$this
->
productRepository
->
getList
(
$criteria
)
->
getItems
();
$productRows
[
'header'
]
=
$this
->
generateRow
(
$this
->
columns
);
foreach
(
$products
as
$key
=>
$product
)
{
$_product
=
$this
->
productRepository
->
getById
(
$product
->
getId
());
$data
=
$this
->
generateProductData
(
$_product
);
if
(
count
(
$data
)
>
0
)
{
$productRows
[
$key
]
=
$this
->
generateRow
(
$data
);
}
}
$feedContent
=
''
;
foreach
(
$productRows
as
$productRow
)
{
$feedContent
.=
$productRow
.
"
\n
"
;
}
$media
=
$this
->
filesystem
->
getDirectoryWrite
(
$this
->
directoryList
::
PUB
);
$media
->
writeFile
(
"feed/facebook.csv"
,
$feedContent
);
$output
->
writeln
(
'<info>Facebook Feed generated in /pub/feed/facebook.csv</info>'
);
}
/**
* @param $productId
* @return mixed
*/
public
function
getStockItem
(
$productId
)
{
return
$this
->
stockItemRepository
->
get
(
$productId
);
}
/**
* @param $rowData
* @return string
*/
public
function
generateRow
(
$rowData
)
{
$row
=
''
;
foreach
(
$rowData
as
$column
)
{
$row
.=
'"'
.
$column
.
'",'
;
}
return
substr
(
$row
,
0
,
-
1
);
}
/**
* @param $product
* @return array
*/
public
function
generateProductData
(
$product
)
{
$data
=
array
();
$flag0price
=
false
;
if
(
$product
)
{
$data
[
'id'
]
=
$product
->
getSku
();
$data
[
'title'
]
=
str_replace
(
'"'
,
'\''
,
$product
->
getName
());
$data
[
'description'
]
=
strip_tags
(
str_replace
(
'"'
,
'\''
,
$product
->
getShortDescription
()));
$data
[
'availability'
]
=
"In Stock"
;
$data
[
'condition'
]
=
'new'
;
if
(
$product
->
getTypeId
()
==
'configurable'
)
{
$basePrice
=
$product
->
getPriceInfo
()
->
getPrice
(
'regular_price'
);
$regular_price
=
$basePrice
->
getMinRegularAmount
()
->
getValue
();
$finalPriceAmt
=
$product
->
getFinalPrice
();
}
else
{
$regular_price
=
$product
->
getPriceInfo
()
->
getPrice
(
'regular_price'
)
->
getValue
();
$finalPriceAmt
=
$product
->
getPriceInfo
()
->
getPrice
(
'final_price'
)
->
getValue
();
}
$data
[
'price'
]
=
number_format
(
$regular_price
,
2
)
.
' USD'
;
$currentStore
=
$this
->
storeManager
->
getStore
();
$mediaUrl
=
$currentStore
->
getBaseUrl
(
\Magento\Framework\UrlInterface
::
URL_TYPE_MEDIA
);
$data
[
'link'
]
=
$product
->
getProductUrl
();
$data
[
'image_link'
]
=
$mediaUrl
.
'catalog/product'
.
$product
->
getImage
();
$data
[
'brand'
]
=
"Joshine"
;
$data
[
'google_product_category'
]
=
''
;
$data
[
'fb_product_category'
]
=
''
;
$data
[
'quantity_to_sell_on_facebook'
]
=
''
;
$data
[
'sale_price'
]
=
number_format
(
$finalPriceAmt
,
2
)
.
' USD'
;
$data
[
'sale_price_effective_date'
]
=
''
;
$data
[
'item_group_id'
]
=
''
;
$data
[
'gender'
]
=
''
;
$data
[
'color'
]
=
''
;
$data
[
'size'
]
=
''
;
$data
[
'age_group'
]
=
''
;
$data
[
'material'
]
=
''
;
$data
[
'pattern'
]
=
''
;
$data
[
'shipping'
]
=
''
;
$data
[
'shipping_weight'
]
=
''
;
$data
[
'style[0]'
]
=
''
;
if
(
$regular_price
<
0.01
)
{
$flag0price
=
true
;
}
}
if
(
$flag0price
)
{
$data
=
array
();
}
return
$data
;
}
/**
* Get Store name
*
* @return string
*/
public
function
getStoreName
()
{
return
$this
->
storeManager
->
getStore
()
->
getName
();
}
}
app/code/Joshine/facebookfeed/etc/di.xml
0 → 100644
View file @
66766da9
<?xml version="1.0"?>
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:ObjectManager/etc/config.xsd"
>
<type
name=
"Magento\Framework\Console\CommandListInterface"
>
<arguments>
<argument
name=
"commands"
xsi:type=
"array"
>
<item
name=
"facebookfeed"
xsi:type=
"object"
>
Joshine\FacebookFeed\Console\Command\FacebookFeed
</item>
</argument>
</arguments>
</type>
</config>
app/code/Joshine/facebookfeed/etc/module.xml
0 → 100644
View file @
66766da9
<?xml version="1.0" ?>
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:Module/etc/module.xsd"
>
<module
name=
"Joshine_FacebookFeed"
setup_version=
"1.0.1"
>
>
<sequence>
<module
name=
"Magento_Catalog"
/>
</sequence>
</module>
</config>
app/code/Joshine/facebookfeed/registration.php
0 → 100644
View file @
66766da9
<?php
\Magento\Framework\Component\ComponentRegistrar
::
register
(
\Magento\Framework\Component\ComponentRegistrar
::
MODULE
,
'Joshine_FacebookFeed'
,
__DIR__
);
vendor/magento/module-aws-s3-page-builder/Test/Mftf/Suite/RemoteStorageAwsS3EnabledPageBuilderSuite.xml
0 → 100644
View file @
66766da9
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<suites
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:mftf:Suite/etc/suiteSchema.xsd"
>
<suite
name=
"RemoteStorageAwsS3EnabledPageBuilderSuite"
>
<before>
<magentoCLI
command=
"setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}"
stepKey=
"enableRemoteStorage"
/>
<magentoCLI
command=
"config:set cms/pagebuilder/enabled 1"
stepKey=
"enablePageBuilder"
/>
<magentoCLI
command=
"config:set cms/wysiwyg/enabled enabled"
stepKey=
"enableWYSIWYG"
/>
<actionGroup
ref=
"CliEnableTinyMCEActionGroup"
stepKey=
"enableTinyMCE"
>
<argument
name=
"TinyMCEValue"
value=
"{{EnableTinyMCE.value}}"
/>
</actionGroup>
<magentoCLI
command=
"config:set cms/pagebuilder/google_maps_api_key ''"
stepKey=
"setEmptyGoogleMapsAPIKey"
/>
<magentoCLI
command=
"config:set web/default_layouts/default_cms_layout cms-full-width"
stepKey=
"setPageBuilderDefaultCmsLayout"
/>
<magentoCLI
command=
"config:set web/default_layouts/default_category_layout category-full-width"
stepKey=
"setPageBuilderDefaultCategoryLayout"
/>
<magentoCLI
command=
"config:set web/default_layouts/default_product_layout product-full-width"
stepKey=
"setPageBuilderDefaultProductLayout"
/>
<magentoCLI
command=
"cache:clean config"
stepKey=
"flushCache"
/>
</before>
<after>
<magentoCLI
command=
"setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}"
stepKey=
"disableRemoteStorage"
/>
<magentoCLI
command=
"config:set cms/pagebuilder/enabled 1"
stepKey=
"enablePageBuilder"
/>
<actionGroup
ref=
"CliEnableTinyMCEActionGroup"
stepKey=
"enableTinyMCE"
>
<argument
name=
"TinyMCEValue"
value=
"{{EnableTinyMCE.value}}"
/>
</actionGroup>
<magentoCLI
command=
"config:set cms/wysiwyg/enabled disabled"
stepKey=
"disableWYSIWYG"
/>
<magentoCLI
command=
"config:set cms/pagebuilder/google_maps_api_key ''"
stepKey=
"setEmptyGoogleMapsAPIKey"
/>
<magentoCLI
command=
"cache:clean config"
stepKey=
"flushCache"
/>
</after>
<include>
<group
name=
"remote_storage_aws_s3_pagebuilder"
/>
</include>
</suite>
</suites>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment