repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
avored/framework | src/Shipping/FreeShipping.php | FreeShipping.enable | public function enable()
{
$configModel = new Configuration();
$this->enable = $configModel->getConfiguration(self::CONFIG_KEY);
return $this->enable;
} | php | public function enable()
{
$configModel = new Configuration();
$this->enable = $configModel->getConfiguration(self::CONFIG_KEY);
return $this->enable;
} | [
"public",
"function",
"enable",
"(",
")",
"{",
"$",
"configModel",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"this",
"->",
"enable",
"=",
"$",
"configModel",
"->",
"getConfiguration",
"(",
"self",
"::",
"CONFIG_KEY",
")",
";",
"return",
"$",
"this... | Get the Name of the Shipping Option.
return string $title | [
"Get",
"the",
"Name",
"of",
"the",
"Shipping",
"Option",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Shipping/FreeShipping.php#L70-L76 | train |
avored/framework | src/Shipping/FreeShipping.php | FreeShipping.amount | public function amount()
{
$orderData = Session::get('order_data');
$cartProducts = Session::get('cart');
$this->process($orderData, $cartProducts);
return $this->amount;
} | php | public function amount()
{
$orderData = Session::get('order_data');
$cartProducts = Session::get('cart');
$this->process($orderData, $cartProducts);
return $this->amount;
} | [
"public",
"function",
"amount",
"(",
")",
"{",
"$",
"orderData",
"=",
"Session",
"::",
"get",
"(",
"'order_data'",
")",
";",
"$",
"cartProducts",
"=",
"Session",
"::",
"get",
"(",
"'cart'",
")",
";",
"$",
"this",
"->",
"process",
"(",
"$",
"orderData",... | Calculate and Return the Amount.
return float $amount | [
"Calculate",
"and",
"Return",
"the",
"Amount",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Shipping/FreeShipping.php#L83-L90 | train |
avored/framework | src/Shipping/FreeShipping.php | FreeShipping.calculate | public function calculate($checkoutFormData)
{
$view = view($this->view)->with('shippingOption', $this);
return $view->render();
} | php | public function calculate($checkoutFormData)
{
$view = view($this->view)->with('shippingOption', $this);
return $view->render();
} | [
"public",
"function",
"calculate",
"(",
"$",
"checkoutFormData",
")",
"{",
"$",
"view",
"=",
"view",
"(",
"$",
"this",
"->",
"view",
")",
"->",
"with",
"(",
"'shippingOption'",
",",
"$",
"this",
")",
";",
"return",
"$",
"view",
"->",
"render",
"(",
"... | Calculate the cost of Shipping based on Checkout Form Data.
@param \Illuminate\Support\Collection $cartProducts
@return self | [
"Calculate",
"the",
"cost",
"of",
"Shipping",
"based",
"on",
"Checkout",
"Form",
"Data",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Shipping/FreeShipping.php#L132-L137 | train |
avored/framework | src/DataGrid/Columns/AbstractColumn.php | AbstractColumn.sortable | public function sortable($order = null)
{
if (null === $order) {
return $this->sortable;
}
$this->sortable = $order;
return $this;
} | php | public function sortable($order = null)
{
if (null === $order) {
return $this->sortable;
}
$this->sortable = $order;
return $this;
} | [
"public",
"function",
"sortable",
"(",
"$",
"order",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"order",
")",
"{",
"return",
"$",
"this",
"->",
"sortable",
";",
"}",
"$",
"this",
"->",
"sortable",
"=",
"$",
"order",
";",
"return",
"$",
... | Get the Column Type.
@return string $type | [
"Get",
"the",
"Column",
"Type",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/Columns/AbstractColumn.php#L58-L66 | train |
avored/framework | src/DataGrid/Columns/AbstractColumn.php | AbstractColumn.identifier | public function identifier($identifier = null)
{
if (null === $identifier) {
return $this->identifier;
}
$this->identifier = $identifier;
return $this;
} | php | public function identifier($identifier = null)
{
if (null === $identifier) {
return $this->identifier;
}
$this->identifier = $identifier;
return $this;
} | [
"public",
"function",
"identifier",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"identifier",
")",
"{",
"return",
"$",
"this",
"->",
"identifier",
";",
"}",
"$",
"this",
"->",
"identifier",
"=",
"$",
"identifier",
";",... | Get the column identifier.
@return string $identifier | [
"Get",
"the",
"column",
"identifier",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/Columns/AbstractColumn.php#L114-L122 | train |
avored/framework | src/DataGrid/DataGrid.php | DataGrid.column | public function column($identifier, $options = []):self
{
if (is_callable($options)) {
$column = new TextColumn($identifier, $options);
} else {
$column = new TextColumn($identifier, $options);
}
$this->columns->put($identifier, $column);
return $this;
} | php | public function column($identifier, $options = []):self
{
if (is_callable($options)) {
$column = new TextColumn($identifier, $options);
} else {
$column = new TextColumn($identifier, $options);
}
$this->columns->put($identifier, $column);
return $this;
} | [
"public",
"function",
"column",
"(",
"$",
"identifier",
",",
"$",
"options",
"=",
"[",
"]",
")",
":",
"self",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"options",
")",
")",
"{",
"$",
"column",
"=",
"new",
"TextColumn",
"(",
"$",
"identifier",
",",
"... | Add Text Columns to the DataGrid Columns.
@param string $identifier
@param array $options
@return \AvoRed\Framework\DataGrid\DataGrid $this; | [
"Add",
"Text",
"Columns",
"to",
"the",
"DataGrid",
"Columns",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/DataGrid.php#L63-L74 | train |
avored/framework | src/DataGrid/DataGrid.php | DataGrid.pageName | public function pageName($pageName = null)
{
if (null === $pageName) {
return $this->pageName;
}
$this->pageName = $pageName;
return $this;
} | php | public function pageName($pageName = null)
{
if (null === $pageName) {
return $this->pageName;
}
$this->pageName = $pageName;
return $this;
} | [
"public",
"function",
"pageName",
"(",
"$",
"pageName",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"pageName",
")",
"{",
"return",
"$",
"this",
"->",
"pageName",
";",
"}",
"$",
"this",
"->",
"pageName",
"=",
"$",
"pageName",
";",
"return",... | Page Name method is used in the event if we want to customize the page request param
It is important in the event of multiple datagrid on same page.
@param null|string $pageName | [
"Page",
"Name",
"method",
"is",
"used",
"in",
"the",
"event",
"if",
"we",
"want",
"to",
"customize",
"the",
"page",
"request",
"param",
"It",
"is",
"important",
"in",
"the",
"event",
"of",
"multiple",
"datagrid",
"on",
"same",
"page",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/DataGrid.php#L107-L116 | train |
avored/framework | src/Models/Database/Category.php | Category.getTranslation | public function getTranslation($languageId = null)
{
$languageId = request()->get('language_id');
if (null === $languageId) {
return $this;
} else {
return $this->translations()->whereLanguageId($languageId)->first();
}
} | php | public function getTranslation($languageId = null)
{
$languageId = request()->get('language_id');
if (null === $languageId) {
return $this;
} else {
return $this->translations()->whereLanguageId($languageId)->first();
}
} | [
"public",
"function",
"getTranslation",
"(",
"$",
"languageId",
"=",
"null",
")",
"{",
"$",
"languageId",
"=",
"request",
"(",
")",
"->",
"get",
"(",
"'language_id'",
")",
";",
"if",
"(",
"null",
"===",
"$",
"languageId",
")",
"{",
"return",
"$",
"this... | Category Model Get Translation Model and return the value
@return \Illuminate\Database\Eloquent\Relations\HasMany | [
"Category",
"Model",
"Get",
"Translation",
"Model",
"and",
"return",
"the",
"value"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Category.php#L42-L50 | train |
avored/framework | src/Theme/Provider.php | Provider.boot | public function boot()
{
$activeTheme = 'avored-default';
$dbConnectError = false;
try {
DB::connection()->getPdo();
} catch (\Exception $e) {
$dbConnectError = true;
}
if (false === $dbConnectError && Schema::hasTable('configurations')) {
$repository = $this->app->get(ConfigurationInterface::class);
$activeTheme = $repository->getValueByKey('active_theme_identifier');
}
$theme = Theme::get($activeTheme);
$fallBackPath = base_path('resources/lang');
$this->app['lang.path'] = array_get($theme, 'lang_path');
} | php | public function boot()
{
$activeTheme = 'avored-default';
$dbConnectError = false;
try {
DB::connection()->getPdo();
} catch (\Exception $e) {
$dbConnectError = true;
}
if (false === $dbConnectError && Schema::hasTable('configurations')) {
$repository = $this->app->get(ConfigurationInterface::class);
$activeTheme = $repository->getValueByKey('active_theme_identifier');
}
$theme = Theme::get($activeTheme);
$fallBackPath = base_path('resources/lang');
$this->app['lang.path'] = array_get($theme, 'lang_path');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"activeTheme",
"=",
"'avored-default'",
";",
"$",
"dbConnectError",
"=",
"false",
";",
"try",
"{",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception"... | Load the Default Theme in the Boot method
@return void | [
"Load",
"the",
"Default",
"Theme",
"in",
"the",
"Boot",
"method"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Theme/Provider.php#L24-L42 | train |
avored/framework | src/Theme/Provider.php | Provider.registerTheme | protected function registerTheme()
{
$this->app->singleton(
'theme',
function ($app) {
$loadDefaultLangPath = base_path('resources/lang');
$app['path.lang'] = $loadDefaultLangPath;
return new Manager($app['files']);
}
);
} | php | protected function registerTheme()
{
$this->app->singleton(
'theme',
function ($app) {
$loadDefaultLangPath = base_path('resources/lang');
$app['path.lang'] = $loadDefaultLangPath;
return new Manager($app['files']);
}
);
} | [
"protected",
"function",
"registerTheme",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'theme'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"loadDefaultLangPath",
"=",
"base_path",
"(",
"'resources/lang'",
")",
";",
"$",
"app",
... | Register the Them Provider instance.
@return void | [
"Register",
"the",
"Them",
"Provider",
"instance",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Theme/Provider.php#L62-L72 | train |
avored/framework | src/Image/Manager.php | Manager.makeSizes | public function makeSizes()
{
$name = basename($this->dbPath);
$path = str_replace('/' . $name, '', $this->dbPath);
$sizes = config('avored-framework.image.sizes');
foreach ($sizes as $sizeName => $widthHeight) {
list($width, $height) = $widthHeight;
$imagePath = storage_path('app/public/' . $path) . DIRECTORY_SEPARATOR . $sizeName . '-' . $name;
$this->driver
->path($this->dbPath)
->make()
->resize($width, $height)
->saveImage($imagePath, 100);
}
return $this;
} | php | public function makeSizes()
{
$name = basename($this->dbPath);
$path = str_replace('/' . $name, '', $this->dbPath);
$sizes = config('avored-framework.image.sizes');
foreach ($sizes as $sizeName => $widthHeight) {
list($width, $height) = $widthHeight;
$imagePath = storage_path('app/public/' . $path) . DIRECTORY_SEPARATOR . $sizeName . '-' . $name;
$this->driver
->path($this->dbPath)
->make()
->resize($width, $height)
->saveImage($imagePath, 100);
}
return $this;
} | [
"public",
"function",
"makeSizes",
"(",
")",
"{",
"$",
"name",
"=",
"basename",
"(",
"$",
"this",
"->",
"dbPath",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
".",
"$",
"name",
",",
"''",
",",
"$",
"this",
"->",
"dbPath",
")",
";",
"$",... | Make Different Sizes of the image based on config
@return self $this | [
"Make",
"Different",
"Sizes",
"of",
"the",
"image",
"based",
"on",
"config"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Manager.php#L56-L74 | train |
avored/framework | src/Image/Manager.php | Manager.directory | public function directory($path)
{
if (!File::exists($path)) {
File::makeDirectory($path, 0775, true, true);
}
return $this;
} | php | public function directory($path)
{
if (!File::exists($path)) {
File::makeDirectory($path, 0775, true, true);
}
return $this;
} | [
"public",
"function",
"directory",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"File",
"::",
"makeDirectory",
"(",
"$",
"path",
",",
"0775",
",",
"true",
",",
"true",
")",
";",
"}",
"return... | Create Directories if not exists.
@var string $path
@return self $this | [
"Create",
"Directories",
"if",
"not",
"exists",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Image/Manager.php#L82-L88 | train |
avored/framework | src/DataGrid/Manager.php | Manager.make | public function make($name):DataGrid
{
$dataGrid = new DataGrid($this->request);
$this->collection->put($name, $dataGrid);
return $dataGrid;
} | php | public function make($name):DataGrid
{
$dataGrid = new DataGrid($this->request);
$this->collection->put($name, $dataGrid);
return $dataGrid;
} | [
"public",
"function",
"make",
"(",
"$",
"name",
")",
":",
"DataGrid",
"{",
"$",
"dataGrid",
"=",
"new",
"DataGrid",
"(",
"$",
"this",
"->",
"request",
")",
";",
"$",
"this",
"->",
"collection",
"->",
"put",
"(",
"$",
"name",
",",
"$",
"dataGrid",
"... | DataGrid Make an Object.
@param string $name
@param callable $callable
@return void | [
"DataGrid",
"Make",
"an",
"Object",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/Manager.php#L74-L80 | train |
avored/framework | src/DataGrid/Manager.php | Manager.render | public function render($dataGrid)
{
if (null !== $this->request->get('q')) {
foreach ($this->request->get('q') as $key => $val) {
$dataGrid->model->where($key, 'like', '%' . $val . '%');
}
}
$options = ['path' => asset(request()->path())];
if (!$dataGrid->model instanceof Collection) {
$dataGrid->data = $dataGrid->model->paginate(
$this->pageItem,
['*'],
$dataGrid->pageName()
);
if (null !== $this->request->get('asc')) {
$dataGrid->model->orderBy($this->request->get('asc'), 'asc');
}
if (null !== $this->request->get('desc', 'id')) {
$dataGrid->model->orderBy($this->request->get('desc', 'id'), 'desc');
}
} else {
$dataGrid->data = $this->paginate(
$dataGrid->model,
$this->pageItem,
null,
$options
);
}
return view('avored-framework::datagrid.grid')->with('dataGrid', $dataGrid);
} | php | public function render($dataGrid)
{
if (null !== $this->request->get('q')) {
foreach ($this->request->get('q') as $key => $val) {
$dataGrid->model->where($key, 'like', '%' . $val . '%');
}
}
$options = ['path' => asset(request()->path())];
if (!$dataGrid->model instanceof Collection) {
$dataGrid->data = $dataGrid->model->paginate(
$this->pageItem,
['*'],
$dataGrid->pageName()
);
if (null !== $this->request->get('asc')) {
$dataGrid->model->orderBy($this->request->get('asc'), 'asc');
}
if (null !== $this->request->get('desc', 'id')) {
$dataGrid->model->orderBy($this->request->get('desc', 'id'), 'desc');
}
} else {
$dataGrid->data = $this->paginate(
$dataGrid->model,
$this->pageItem,
null,
$options
);
}
return view('avored-framework::datagrid.grid')->with('dataGrid', $dataGrid);
} | [
"public",
"function",
"render",
"(",
"$",
"dataGrid",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'q'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'q'",
")",
"as",
"$",... | Render the Datagrid by given datagrid object
@param \AvoRed\Framework\DataGrid\DataGrid
@return \Illuminate\View\View $response | [
"Render",
"the",
"Datagrid",
"by",
"given",
"datagrid",
"object"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/Manager.php#L98-L130 | train |
avored/framework | src/DataGrid/Manager.php | Manager.linkColumn | public function linkColumn($identifier, $options = [], $callback)
{
$column = new LinkColumn($identifier, $options, $callback);
$this->columns->put($identifier, $column);
return $this;
} | php | public function linkColumn($identifier, $options = [], $callback)
{
$column = new LinkColumn($identifier, $options, $callback);
$this->columns->put($identifier, $column);
return $this;
} | [
"public",
"function",
"linkColumn",
"(",
"$",
"identifier",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"callback",
")",
"{",
"$",
"column",
"=",
"new",
"LinkColumn",
"(",
"$",
"identifier",
",",
"$",
"options",
",",
"$",
"callback",
")",
";",
"$",... | I feel this method is moved to DataGrid file | [
"I",
"feel",
"this",
"method",
"is",
"moved",
"to",
"DataGrid",
"file"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/DataGrid/Manager.php#L181-L187 | train |
avored/framework | src/Models/Repository/PropertyRepository.php | PropertyRepository.update | public function update($property, $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $property->update($data);
} else {
$translatedModel = $property
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return PropertyTranslation::create(
array_merge($data, ['property_id' => $property->id])
);
} else {
$translatedModel->update(
$data,
$property->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $category->update($data);
}
} | php | public function update($property, $data)
{
if (Session::has('multi_language_enabled')) {
$languageId = $data['language_id'];
$languaModel = Language::find($languageId);
if ($languaModel->is_default) {
return $property->update($data);
} else {
$translatedModel = $property
->translations()
->whereLanguageId($languageId)
->first();
if (null === $translatedModel) {
return PropertyTranslation::create(
array_merge($data, ['property_id' => $property->id])
);
} else {
$translatedModel->update(
$data,
$property->getTranslatedAttributes()
);
return $translatedModel;
}
}
} else {
return $category->update($data);
}
} | [
"public",
"function",
"update",
"(",
"$",
"property",
",",
"$",
"data",
")",
"{",
"if",
"(",
"Session",
"::",
"has",
"(",
"'multi_language_enabled'",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"data",
"[",
"'language_id'",
"]",
";",
"$",
"languaModel",
... | Update Product Property
@param array $data
@param \AvoRed\Framework\Models\Database\Property
@return \AvoRed\Framework\Models\Database\Property | [
"Update",
"Product",
"Property"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/PropertyRepository.php#L63-L93 | train |
avored/framework | src/Models/Repository/ConfigurationRepository.php | ConfigurationRepository.getValueByKey | public function getValueByKey($key)
{
$model = Configuration::whereConfigurationKey($key)->first();
if (null === $model) {
return null;
}
return $model->configuration_value;
} | php | public function getValueByKey($key)
{
$model = Configuration::whereConfigurationKey($key)->first();
if (null === $model) {
return null;
}
return $model->configuration_value;
} | [
"public",
"function",
"getValueByKey",
"(",
"$",
"key",
")",
"{",
"$",
"model",
"=",
"Configuration",
"::",
"whereConfigurationKey",
"(",
"$",
"key",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"model",
")",
"{",
"return",
"null",... | Find an Configuration_value by given configurationKey
@param string $key
@return string $configurationValue | [
"Find",
"an",
"Configuration_value",
"by",
"given",
"configurationKey"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/ConfigurationRepository.php#L38-L47 | train |
avored/framework | src/Models/Repository/ConfigurationRepository.php | ConfigurationRepository.setValueByKey | public function setValueByKey($key, $value)
{
$model = Configuration::whereConfigurationKey($key)->first();
if (null === $model) {
return null;
}
$model->update(['configuration_value' => $value]);
return $model;
} | php | public function setValueByKey($key, $value)
{
$model = Configuration::whereConfigurationKey($key)->first();
if (null === $model) {
return null;
}
$model->update(['configuration_value' => $value]);
return $model;
} | [
"public",
"function",
"setValueByKey",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"model",
"=",
"Configuration",
"::",
"whereConfigurationKey",
"(",
"$",
"key",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"model",
")",
"... | Set an Configuration value by given configuration Key
@param string $key
@return string $value | [
"Set",
"an",
"Configuration",
"value",
"by",
"given",
"configuration",
"Key"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/ConfigurationRepository.php#L55-L65 | train |
avored/framework | src/Api/Controllers/ProductController.php | ProductController.destroy | public function destroy($id)
{
$product = Product::find($id);
$product->delete();
return JsonResponse::create(null, 204);
} | php | public function destroy($id)
{
$product = Product::find($id);
$product->delete();
return JsonResponse::create(null, 204);
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"product",
"=",
"Product",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"product",
"->",
"delete",
"(",
")",
";",
"return",
"JsonResponse",
"::",
"create",
"(",
"null",
",",
"204",
")"... | Destroy an Record and Return Null Json Response
@return \Illuminate\Http\JsonResponse | [
"Destroy",
"an",
"Record",
"and",
"Return",
"Null",
"Json",
"Response"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Api/Controllers/ProductController.php#L65-L70 | train |
avored/framework | src/Theme/Manager.php | Manager.get | public function get($identifier)
{
if ($this->themeLoaded === false) {
$this->loadThemes();
}
return $this->themeList->get($identifier);
} | php | public function get($identifier)
{
if ($this->themeLoaded === false) {
$this->loadThemes();
}
return $this->themeList->get($identifier);
} | [
"public",
"function",
"get",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"themeLoaded",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"loadThemes",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"themeList",
"->",
"get",
"(",
"... | Get the theme into an collection
@param string $identifier
@return array $themInfo | [
"Get",
"the",
"theme",
"into",
"an",
"collection"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Theme/Manager.php#L114-L121 | train |
avored/framework | src/Theme/Manager.php | Manager.getByPath | public function getByPath($path)
{
foreach ($this->themeList as $theme => $themeInfo) {
$path1 = $this->pathSlashFix($path);
$path2 = $this->pathSlashFix($themeInfo['path']);
if ($path1 == $path2) {
$actualTheme = $this->themeList[$theme];
break;
}
}
return $actualTheme;
} | php | public function getByPath($path)
{
foreach ($this->themeList as $theme => $themeInfo) {
$path1 = $this->pathSlashFix($path);
$path2 = $this->pathSlashFix($themeInfo['path']);
if ($path1 == $path2) {
$actualTheme = $this->themeList[$theme];
break;
}
}
return $actualTheme;
} | [
"public",
"function",
"getByPath",
"(",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"themeList",
"as",
"$",
"theme",
"=>",
"$",
"themeInfo",
")",
"{",
"$",
"path1",
"=",
"$",
"this",
"->",
"pathSlashFix",
"(",
"$",
"path",
")",
";",
"... | Get the ThemeInfo By Path
@param string $path
@return array $themInfo | [
"Get",
"the",
"ThemeInfo",
"By",
"Path"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Theme/Manager.php#L129-L142 | train |
avored/framework | src/Product/Controllers/ProductController.php | ProductController.index | public function index()
{
$productsBuilder = $this
->repository
->query()
->where('type', '!=', 'VARIABLE_PRODUCT')
->orderBy('id', 'desc');
$productGrid = new ProductDataGrid($productsBuilder);
return view('avored-framework::product.index')
->with('dataGrid', $productGrid->dataGrid);
} | php | public function index()
{
$productsBuilder = $this
->repository
->query()
->where('type', '!=', 'VARIABLE_PRODUCT')
->orderBy('id', 'desc');
$productGrid = new ProductDataGrid($productsBuilder);
return view('avored-framework::product.index')
->with('dataGrid', $productGrid->dataGrid);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"productsBuilder",
"=",
"$",
"this",
"->",
"repository",
"->",
"query",
"(",
")",
"->",
"where",
"(",
"'type'",
",",
"'!='",
",",
"'VARIABLE_PRODUCT'",
")",
"->",
"orderBy",
"(",
"'id'",
",",
"'desc'",
... | Display a listing of the resource.
r.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
".",
"r",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Product/Controllers/ProductController.php#L48-L60 | train |
avored/framework | src/Product/Controllers/ProductController.php | ProductController.uploadImage | public function uploadImage(Request $request)
{
$image = $request->image;
$tmpPath = str_split(strtolower(str_random(3)));
$checkDirectory = 'uploads/catalog/images/' . implode('/', $tmpPath);
$dbPath = $checkDirectory . '/' . $image->getClientOriginalName();
$image = Image::upload(
$request->file('image'),
$checkDirectory
)->makeSizes()->get();
$tmp = $this->_getTmpString();
return view('avored-framework::product.upload-image')
->with('image', $image)
->with('tmp', $tmp);
} | php | public function uploadImage(Request $request)
{
$image = $request->image;
$tmpPath = str_split(strtolower(str_random(3)));
$checkDirectory = 'uploads/catalog/images/' . implode('/', $tmpPath);
$dbPath = $checkDirectory . '/' . $image->getClientOriginalName();
$image = Image::upload(
$request->file('image'),
$checkDirectory
)->makeSizes()->get();
$tmp = $this->_getTmpString();
return view('avored-framework::product.upload-image')
->with('image', $image)
->with('tmp', $tmp);
} | [
"public",
"function",
"uploadImage",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"image",
"=",
"$",
"request",
"->",
"image",
";",
"$",
"tmpPath",
"=",
"str_split",
"(",
"strtolower",
"(",
"str_random",
"(",
"3",
")",
")",
")",
";",
"$",
"checkDirec... | upload image file and re sized it.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"upload",
"image",
"file",
"and",
"re",
"sized",
"it",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Product/Controllers/ProductController.php#L161-L179 | train |
avored/framework | src/Models/Traits/TranslatedAttributes.php | TranslatedAttributes.getAttribute | public function getAttribute($key, $translated = false)
{
if (false === $translated) {
return parent::getAttribute($key);
}
$defaultLanguage = Session::get('default_language');
$languageId = request()->get('language_id', $defaultLanguage->id);
if (in_array($key, $this->getTranslatedAttributes())
&& $defaultLanguage->id != $languageId
) {
$translatedModel = $this->translations()
->whereLanguageId($languageId)
->first();
if ($translatedModel === null) {
return null;
}
return $translatedModel->attributes[$key];
}
return parent::getAttribute($key);
} | php | public function getAttribute($key, $translated = false)
{
if (false === $translated) {
return parent::getAttribute($key);
}
$defaultLanguage = Session::get('default_language');
$languageId = request()->get('language_id', $defaultLanguage->id);
if (in_array($key, $this->getTranslatedAttributes())
&& $defaultLanguage->id != $languageId
) {
$translatedModel = $this->translations()
->whereLanguageId($languageId)
->first();
if ($translatedModel === null) {
return null;
}
return $translatedModel->attributes[$key];
}
return parent::getAttribute($key);
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"key",
",",
"$",
"translated",
"=",
"false",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"translated",
")",
"{",
"return",
"parent",
"::",
"getAttribute",
"(",
"$",
"key",
")",
";",
"}",
"$",
"defaultLangua... | Get the Attribute of an model
@param string $key
@return mixed | [
"Get",
"the",
"Attribute",
"of",
"an",
"model"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Traits/TranslatedAttributes.php#L13-L35 | train |
avored/framework | src/System/Controllers/ModuleController.php | ModuleController.index | public function index()
{
$modules = Module::all();
$moduleDataGrid = new ModuleDataGrid($modules);
return view('avored-framework::system.module.index')
->with('modules', $modules)
->with('dataGrid', $moduleDataGrid->dataGrid);
} | php | public function index()
{
$modules = Module::all();
$moduleDataGrid = new ModuleDataGrid($modules);
return view('avored-framework::system.module.index')
->with('modules', $modules)
->with('dataGrid', $moduleDataGrid->dataGrid);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"modules",
"=",
"Module",
"::",
"all",
"(",
")",
";",
"$",
"moduleDataGrid",
"=",
"new",
"ModuleDataGrid",
"(",
"$",
"modules",
")",
";",
"return",
"view",
"(",
"'avored-framework::system.module.index'",
")"... | Display a listing of the modules.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"modules",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/System/Controllers/ModuleController.php#L17-L25 | train |
avored/framework | src/System/Controllers/ModuleController.php | ModuleController.store | public function store(UploadModuleRequest $request)
{
$path = storage_path('app/' . $request->module_zip_file->store('public/uploads/modules'));
$zip = new ZipArchive;
if ($zip->open($path) === true) {
$extractPath = base_path('modules');
$zip->extractTo($extractPath);
$zip->close();
return redirect()->route('admin.module.index')
->with('notificationText', 'Module Extracted successfully');
} else {
return redirect()
->back()
->with('errorNotificationText', 'There is some issue: Please check your permission and try again later!');
}
} | php | public function store(UploadModuleRequest $request)
{
$path = storage_path('app/' . $request->module_zip_file->store('public/uploads/modules'));
$zip = new ZipArchive;
if ($zip->open($path) === true) {
$extractPath = base_path('modules');
$zip->extractTo($extractPath);
$zip->close();
return redirect()->route('admin.module.index')
->with('notificationText', 'Module Extracted successfully');
} else {
return redirect()
->back()
->with('errorNotificationText', 'There is some issue: Please check your permission and try again later!');
}
} | [
"public",
"function",
"store",
"(",
"UploadModuleRequest",
"$",
"request",
")",
"{",
"$",
"path",
"=",
"storage_path",
"(",
"'app/'",
".",
"$",
"request",
"->",
"module_zip_file",
"->",
"store",
"(",
"'public/uploads/modules'",
")",
")",
";",
"$",
"zip",
"="... | Store and Extract upload module zip files
@param \AvoRed\Framework\Http\Requests\UploadModuleRequest $request
@return \Illuminate\Http\RedirectResponse | [
"Store",
"and",
"Extract",
"upload",
"module",
"zip",
"files"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/System/Controllers/ModuleController.php#L43-L61 | train |
avored/framework | src/Models/Database/Product.php | Product.getProductVariationJsonData | public function getProductVariationJsonData()
{
$jsonData = [];
$lists = ProductAttributeIntegerValue::whereIn(
'product_id',
$this->productVariations->pluck('variation_id')
)->get();
foreach ($lists as $list) {
$variationModel = self::find($list->product_id);
if (array_has($jsonData, $list->product_id)) {
$data = array_get($jsonData, $list->product_id);
$data[$list->attribute_id] = [
$list->value => ['qty' => $variationModel->qty, 'price' => $variationModel->price]
];
$jsonData[$list->product_id] = $data;
} else {
$jsonData[$list->product_id] = [$list->attribute_id => [
$list->value => ['qty' => $variationModel->qty, 'price' => $variationModel->price]]
];
}
}
return $jsonData;
} | php | public function getProductVariationJsonData()
{
$jsonData = [];
$lists = ProductAttributeIntegerValue::whereIn(
'product_id',
$this->productVariations->pluck('variation_id')
)->get();
foreach ($lists as $list) {
$variationModel = self::find($list->product_id);
if (array_has($jsonData, $list->product_id)) {
$data = array_get($jsonData, $list->product_id);
$data[$list->attribute_id] = [
$list->value => ['qty' => $variationModel->qty, 'price' => $variationModel->price]
];
$jsonData[$list->product_id] = $data;
} else {
$jsonData[$list->product_id] = [$list->attribute_id => [
$list->value => ['qty' => $variationModel->qty, 'price' => $variationModel->price]]
];
}
}
return $jsonData;
} | [
"public",
"function",
"getProductVariationJsonData",
"(",
")",
"{",
"$",
"jsonData",
"=",
"[",
"]",
";",
"$",
"lists",
"=",
"ProductAttributeIntegerValue",
"::",
"whereIn",
"(",
"'product_id'",
",",
"$",
"this",
"->",
"productVariations",
"->",
"pluck",
"(",
"... | Get the Product Variation Product Json Data
@return array $jsonData | [
"Get",
"the",
"Product",
"Variation",
"Product",
"Json",
"Data"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L50-L73 | train |
avored/framework | src/Models/Database/Product.php | Product.getPriceAttribute | public function getPriceAttribute($val)
{
$currentCurrencyCode = Session::get('currency_code');
if (null === $currentCurrencyCode) {
return $val;
}
$siteCurrency = App::get(SiteCurrencyInterface::class);
$model = $siteCurrency->findByCode($currentCurrencyCode);
return $val * $model->conversion_rate;
} | php | public function getPriceAttribute($val)
{
$currentCurrencyCode = Session::get('currency_code');
if (null === $currentCurrencyCode) {
return $val;
}
$siteCurrency = App::get(SiteCurrencyInterface::class);
$model = $siteCurrency->findByCode($currentCurrencyCode);
return $val * $model->conversion_rate;
} | [
"public",
"function",
"getPriceAttribute",
"(",
"$",
"val",
")",
"{",
"$",
"currentCurrencyCode",
"=",
"Session",
"::",
"get",
"(",
"'currency_code'",
")",
";",
"if",
"(",
"null",
"===",
"$",
"currentCurrencyCode",
")",
"{",
"return",
"$",
"val",
";",
"}",... | Get the Price for the Product
@param float $val
@return float $price | [
"Get",
"the",
"Price",
"for",
"the",
"Product"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L114-L126 | train |
avored/framework | src/Models/Database/Product.php | Product.saveProductImages | public function saveProductImages(array $data):self
{
if (isset($data['image']) && count($data['image']) > 0) {
$exitingIds = $this->images()->get()->pluck('id')->toArray();
foreach ($data['image'] as $key => $data) {
if (is_int($key)) {
if (($findKey = array_search($key, $exitingIds)) !== false) {
$productImage = ProductImage::findorfail($key);
$productImage->update($data);
unset($exitingIds[$findKey]);
}
continue;
}
ProductImage::create($data + ['product_id' => $this->id]);
}
if (count($exitingIds) > 0) {
ProductImage::destroy($exitingIds);
}
}
return $this;
} | php | public function saveProductImages(array $data):self
{
if (isset($data['image']) && count($data['image']) > 0) {
$exitingIds = $this->images()->get()->pluck('id')->toArray();
foreach ($data['image'] as $key => $data) {
if (is_int($key)) {
if (($findKey = array_search($key, $exitingIds)) !== false) {
$productImage = ProductImage::findorfail($key);
$productImage->update($data);
unset($exitingIds[$findKey]);
}
continue;
}
ProductImage::create($data + ['product_id' => $this->id]);
}
if (count($exitingIds) > 0) {
ProductImage::destroy($exitingIds);
}
}
return $this;
} | [
"public",
"function",
"saveProductImages",
"(",
"array",
"$",
"data",
")",
":",
"self",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'image'",
"]",
")",
"&&",
"count",
"(",
"$",
"data",
"[",
"'image'",
"]",
")",
">",
"0",
")",
"{",
"$",
"exit... | Save Product Images.
@param array $$data
@return \AvoRed\Framework\Models\Database\Product $this | [
"Save",
"Product",
"Images",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L134-L154 | train |
avored/framework | src/Models/Database/Product.php | Product.saveProduct | public function saveProduct($data)
{
Event::fire(new ProductBeforeSave($data));
$this->update($data);
$this->saveProductImages($data);
$this->saveCategoryFilters($data);
$this->saveProductCategories($data);
$this->saveProductProperties($data);
$this->saveProductAttributes($data);
$this->saveProductDownloadable($data);
Event::fire(new ProductAfterSave($this, $data));
return $this;
} | php | public function saveProduct($data)
{
Event::fire(new ProductBeforeSave($data));
$this->update($data);
$this->saveProductImages($data);
$this->saveCategoryFilters($data);
$this->saveProductCategories($data);
$this->saveProductProperties($data);
$this->saveProductAttributes($data);
$this->saveProductDownloadable($data);
Event::fire(new ProductAfterSave($this, $data));
return $this;
} | [
"public",
"function",
"saveProduct",
"(",
"$",
"data",
")",
"{",
"Event",
"::",
"fire",
"(",
"new",
"ProductBeforeSave",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"update",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"saveProductImages",
... | Update the Product and Product Related Data.
@var array $data
@return void | [
"Update",
"the",
"Product",
"and",
"Product",
"Related",
"Data",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L162-L177 | train |
avored/framework | src/Models/Database/Product.php | Product.saveProductCategories | protected function saveProductCategories($data)
{
if (isset($data['category_id']) && count($data['category_id']) > 0) {
$this->categories()->sync($data['category_id']);
}
} | php | protected function saveProductCategories($data)
{
if (isset($data['category_id']) && count($data['category_id']) > 0) {
$this->categories()->sync($data['category_id']);
}
} | [
"protected",
"function",
"saveProductCategories",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'category_id'",
"]",
")",
"&&",
"count",
"(",
"$",
"data",
"[",
"'category_id'",
"]",
")",
">",
"0",
")",
"{",
"$",
"this",
"->"... | Save Product Categories
@param array $data
@return void | [
"Save",
"Product",
"Categories"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L185-L190 | train |
avored/framework | src/Models/Database/Product.php | Product.saveProductDownloadable | protected function saveProductDownloadable($data)
{
if (isset($data['downloadable']) && count($data['downloadable']) > 0) {
$repository = App::get(ProductDownloadableUrlInterface::class);
$mainDownloadableMedia = ($data['downloadable']['main_product']) ?? null;
if (null === $mainDownloadableMedia) {
throw new \Exception('Invalid Downloadable Media Given or Nothing Given');
}
$tmpPath = str_split(strtolower(str_random(3)));
$path = 'uploads/downloadables/' . implode('/', $tmpPath);
$dbPath = $mainDownloadableMedia->store($path, 'avored');
$token = str_random(32);
$downModel = $repository->query()->whereProductId($this->id)->first();
if (null === $downModel) {
$downModel = ProductDownloadableUrl::create([
'token' => $token,
'product_id' => $this->id,
'main_path' => $dbPath
]);
} else {
$downModel->update(['main_path' => $dbPath]);
}
$demoDownloadableMedia = ($data['downloadable']['demo_product']) ?? null;
if (null !== $demoDownloadableMedia) {
$tmpPath = str_split(strtolower(str_random(3)));
$path = 'uploads/downloadables/' . implode('/', $tmpPath);
$demoDbPath = $demoDownloadableMedia->store($path, 'avored');
$downModel->update(['demo_path' => $demoDbPath]);
}
}
} | php | protected function saveProductDownloadable($data)
{
if (isset($data['downloadable']) && count($data['downloadable']) > 0) {
$repository = App::get(ProductDownloadableUrlInterface::class);
$mainDownloadableMedia = ($data['downloadable']['main_product']) ?? null;
if (null === $mainDownloadableMedia) {
throw new \Exception('Invalid Downloadable Media Given or Nothing Given');
}
$tmpPath = str_split(strtolower(str_random(3)));
$path = 'uploads/downloadables/' . implode('/', $tmpPath);
$dbPath = $mainDownloadableMedia->store($path, 'avored');
$token = str_random(32);
$downModel = $repository->query()->whereProductId($this->id)->first();
if (null === $downModel) {
$downModel = ProductDownloadableUrl::create([
'token' => $token,
'product_id' => $this->id,
'main_path' => $dbPath
]);
} else {
$downModel->update(['main_path' => $dbPath]);
}
$demoDownloadableMedia = ($data['downloadable']['demo_product']) ?? null;
if (null !== $demoDownloadableMedia) {
$tmpPath = str_split(strtolower(str_random(3)));
$path = 'uploads/downloadables/' . implode('/', $tmpPath);
$demoDbPath = $demoDownloadableMedia->store($path, 'avored');
$downModel->update(['demo_path' => $demoDbPath]);
}
}
} | [
"protected",
"function",
"saveProductDownloadable",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'downloadable'",
"]",
")",
"&&",
"count",
"(",
"$",
"data",
"[",
"'downloadable'",
"]",
")",
">",
"0",
")",
"{",
"$",
"repositor... | Save Product Downloadable Information
@param array $data
@return void | [
"Save",
"Product",
"Downloadable",
"Information"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L198-L236 | train |
avored/framework | src/Models/Database/Product.php | Product.getImageAttribute | public function getImageAttribute()
{
$defaultPath = '/img/default-product.jpg';
$image = $this->images()->where('is_main_image', '=', 1)->first();
if (null === $image) {
return new LocalFile($defaultPath);
}
if ($image->path instanceof LocalFile) {
return $image->path;
}
} | php | public function getImageAttribute()
{
$defaultPath = '/img/default-product.jpg';
$image = $this->images()->where('is_main_image', '=', 1)->first();
if (null === $image) {
return new LocalFile($defaultPath);
}
if ($image->path instanceof LocalFile) {
return $image->path;
}
} | [
"public",
"function",
"getImageAttribute",
"(",
")",
"{",
"$",
"defaultPath",
"=",
"'/img/default-product.jpg'",
";",
"$",
"image",
"=",
"$",
"this",
"->",
"images",
"(",
")",
"->",
"where",
"(",
"'is_main_image'",
",",
"'='",
",",
"1",
")",
"->",
"first",... | return default Image or LocalFile Object.
@return \AvoRed\Framework\Image\LocalFile | [
"return",
"default",
"Image",
"or",
"LocalFile",
"Object",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L411-L423 | train |
avored/framework | src/Models/Database/Product.php | Product.getProductAllProperties | public function getProductAllProperties()
{
$collection = Collection::make([]);
foreach ($this->productVarcharProperties as $item) {
$collection->push($item);
}
foreach ($this->productBooleanProperties as $item) {
$collection->push($item);
}
foreach ($this->productTextProperties as $item) {
$collection->push($item);
}
foreach ($this->productDecimalProperties as $item) {
$collection->push($item);
}
foreach ($this->productDecimalProperties as $item) {
$collection->push($item);
}
foreach ($this->productIntegerProperties as $item) {
$collection->push($item);
}
foreach ($this->productDatetimeProperties as $item) {
$collection->push($item);
}
return $collection;
} | php | public function getProductAllProperties()
{
$collection = Collection::make([]);
foreach ($this->productVarcharProperties as $item) {
$collection->push($item);
}
foreach ($this->productBooleanProperties as $item) {
$collection->push($item);
}
foreach ($this->productTextProperties as $item) {
$collection->push($item);
}
foreach ($this->productDecimalProperties as $item) {
$collection->push($item);
}
foreach ($this->productDecimalProperties as $item) {
$collection->push($item);
}
foreach ($this->productIntegerProperties as $item) {
$collection->push($item);
}
foreach ($this->productDatetimeProperties as $item) {
$collection->push($item);
}
return $collection;
} | [
"public",
"function",
"getProductAllProperties",
"(",
")",
"{",
"$",
"collection",
"=",
"Collection",
"::",
"make",
"(",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"productVarcharProperties",
"as",
"$",
"item",
")",
"{",
"$",
"collection",
"->"... | Get All Properties for the Product.
@param Collection $collection
@return \Illuminate\Support\Collection | [
"Get",
"All",
"Properties",
"for",
"the",
"Product",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L431-L464 | train |
avored/framework | src/Models/Database/Product.php | Product.getProductAllAttributes | public function getProductAllAttributes($variation = null)
{
if (null === $variation) {
$variations = $this->productVariations()->get();
}
$collection = Collection::make([]);
if (null === $variations || $variations->count() <= 0) {
return $collection;
}
foreach ($variations as $variation) {
$variationModel = self::findorfail($variation->variation_id);
foreach ($variationModel->productVarcharAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productBooleanAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productTextAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDecimalAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDecimalAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productIntegerAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDatetimeAttributes as $item) {
$collection->push($item);
}
}
return $collection;
} | php | public function getProductAllAttributes($variation = null)
{
if (null === $variation) {
$variations = $this->productVariations()->get();
}
$collection = Collection::make([]);
if (null === $variations || $variations->count() <= 0) {
return $collection;
}
foreach ($variations as $variation) {
$variationModel = self::findorfail($variation->variation_id);
foreach ($variationModel->productVarcharAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productBooleanAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productTextAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDecimalAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDecimalAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productIntegerAttributes as $item) {
$collection->push($item);
}
foreach ($variationModel->productDatetimeAttributes as $item) {
$collection->push($item);
}
}
return $collection;
} | [
"public",
"function",
"getProductAllAttributes",
"(",
"$",
"variation",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"variation",
")",
"{",
"$",
"variations",
"=",
"$",
"this",
"->",
"productVariations",
"(",
")",
"->",
"get",
"(",
")",
";",
"... | Get All Attribute for the Product.
@param $variation
@return \Illuminate\Support\Collection | [
"Get",
"All",
"Attribute",
"for",
"the",
"Product",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L482-L523 | train |
avored/framework | src/Models/Database/Product.php | Product.getVariableProduct | public function getVariableProduct($attributeDropdownOption)
{
$productAttributeIntegerValue = ProductAttributeIntegerValue::
whereAttributeId($attributeDropdownOption->attribute_id)
->whereValue($attributeDropdownOption->id)->first();
if (null === $productAttributeIntegerValue) {
return;
}
return self::findorfail($productAttributeIntegerValue->product_id);
} | php | public function getVariableProduct($attributeDropdownOption)
{
$productAttributeIntegerValue = ProductAttributeIntegerValue::
whereAttributeId($attributeDropdownOption->attribute_id)
->whereValue($attributeDropdownOption->id)->first();
if (null === $productAttributeIntegerValue) {
return;
}
return self::findorfail($productAttributeIntegerValue->product_id);
} | [
"public",
"function",
"getVariableProduct",
"(",
"$",
"attributeDropdownOption",
")",
"{",
"$",
"productAttributeIntegerValue",
"=",
"ProductAttributeIntegerValue",
"::",
"whereAttributeId",
"(",
"$",
"attributeDropdownOption",
"->",
"attribute_id",
")",
"->",
"whereValue",... | Get Variable Product by Attribute Drop down Option.
@param \AvoRed\Framework\Models\Database\AttributeDropdownOption
@return \AvoRed\Framework\Models\Database\ProductVariation | [
"Get",
"Variable",
"Product",
"by",
"Attribute",
"Drop",
"down",
"Option",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Product.php#L531-L542 | train |
avored/framework | src/System/Controllers/RoleController.php | RoleController._saveRolePermissions | private function _saveRolePermissions($request, $role)
{
$permissionIds = [];
if (count($request->get('permissions')) > 0) {
foreach ($request->get('permissions') as $key => $value) {
if ($value != 1) {
continue;
}
$permissions = explode(',', $key);
foreach ($permissions as $permissionName) {
if (null === ($permissionModel = Permission::getPermissionByName($permissionName))) {
$permissionModel = Permission::create(['name' => $permissionName]);
}
$permissionIds[] = $permissionModel->id;
}
}
}
$ids = array_unique($permissionIds);
$role->permissions()->sync($ids);
} | php | private function _saveRolePermissions($request, $role)
{
$permissionIds = [];
if (count($request->get('permissions')) > 0) {
foreach ($request->get('permissions') as $key => $value) {
if ($value != 1) {
continue;
}
$permissions = explode(',', $key);
foreach ($permissions as $permissionName) {
if (null === ($permissionModel = Permission::getPermissionByName($permissionName))) {
$permissionModel = Permission::create(['name' => $permissionName]);
}
$permissionIds[] = $permissionModel->id;
}
}
}
$ids = array_unique($permissionIds);
$role->permissions()->sync($ids);
} | [
"private",
"function",
"_saveRolePermissions",
"(",
"$",
"request",
",",
"$",
"role",
")",
"{",
"$",
"permissionIds",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"request",
"->",
"get",
"(",
"'permissions'",
")",
")",
">",
"0",
")",
"{",
"forea... | Save Role Permission for the Users
@param \AvoRed\Framework\System\Requests\RoleRequest $request
@param \AvoRed\Framework\Models\Database\Role $rolet
@return void | [
"Save",
"Role",
"Permission",
"for",
"the",
"Users"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/System/Controllers/RoleController.php#L120-L140 | train |
avored/framework | src/User/Controllers/UserController.php | UserController.changePasswordUpdate | public function changePasswordUpdate(ChangePasswordRequest $request, User $user)
{
$password = $request->get('password');
$user->update(['password' => bcrypt($password)]);
Mail::to($user->email)->send(new ChangePasswordMail($user, $password));
return redirect()->route('admin.user.index');
} | php | public function changePasswordUpdate(ChangePasswordRequest $request, User $user)
{
$password = $request->get('password');
$user->update(['password' => bcrypt($password)]);
Mail::to($user->email)->send(new ChangePasswordMail($user, $password));
return redirect()->route('admin.user.index');
} | [
"public",
"function",
"changePasswordUpdate",
"(",
"ChangePasswordRequest",
"$",
"request",
",",
"User",
"$",
"user",
")",
"{",
"$",
"password",
"=",
"$",
"request",
"->",
"get",
"(",
"'password'",
")",
";",
"$",
"user",
"->",
"update",
"(",
"[",
"'passwor... | Update the specified User Password in storage.
@param \AvoRed\Framework\User\Requests\ChnagePasswordRequest $request
@param \AvoRed\Framework\Models\Database\User $user
@return \Illuminate\Http\RedirectResponse | [
"Update",
"the",
"specified",
"User",
"Password",
"in",
"storage",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/User/Controllers/UserController.php#L143-L150 | train |
avored/framework | src/Models/Database/ProductImage.php | ProductImage.getPathAttribute | public function getPathAttribute($path)
{
if (null === $this->attributes['path'] || empty($this->attributes['path'])) {
return;
}
$symlink = config('avored-framework.symlink_storage_folder');
$relativePath = $this->attributes['path'];
$localImage = new LocalFile($relativePath);
return $localImage;
} | php | public function getPathAttribute($path)
{
if (null === $this->attributes['path'] || empty($this->attributes['path'])) {
return;
}
$symlink = config('avored-framework.symlink_storage_folder');
$relativePath = $this->attributes['path'];
$localImage = new LocalFile($relativePath);
return $localImage;
} | [
"public",
"function",
"getPathAttribute",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"attributes",
"[",
"'path'",
"]",
"||",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
";"... | Get Path Attribute for the Image
@param string $path
@return \AvoRed\Framework\Image\LocalFile $localImage | [
"Get",
"Path",
"Attribute",
"for",
"the",
"Image"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/ProductImage.php#L31-L42 | train |
avored/framework | src/Models/Repository/CountryRepository.php | CountryRepository.options | public function options()
{
$countries = $this->all();
$options = Collection::make();
foreach ($countries as $country) {
$options->push(['name' => $country->name, 'id' => $country->id]);
}
return $options;
} | php | public function options()
{
$countries = $this->all();
$options = Collection::make();
foreach ($countries as $country) {
$options->push(['name' => $country->name, 'id' => $country->id]);
}
return $options;
} | [
"public",
"function",
"options",
"(",
")",
"{",
"$",
"countries",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"options",
"=",
"Collection",
"::",
"make",
"(",
")",
";",
"foreach",
"(",
"$",
"countries",
"as",
"$",
"country",
")",
"{",
"$",
... | Get All Country Options for Dropdown Field
@return \Illuminate\Database\Eloquent\Collection | [
"Get",
"All",
"Country",
"Options",
"for",
"Dropdown",
"Field"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CountryRepository.php#L67-L75 | train |
avored/framework | src/Api/Controllers/LoginController.php | LoginController.createRequest | protected function createRequest($client, $userId, $request, array $scopes)
{
return (new ServerRequest)->withParsedBody(
['grant_type' => 'password',
'client_id' => $client->id,
'client_secret' => $client->secret,
'username' => $request->get('email'),
'password' => $request->get('password'),
'user_id' => $userId,
'scope' => implode(' ', $scopes)]
);
} | php | protected function createRequest($client, $userId, $request, array $scopes)
{
return (new ServerRequest)->withParsedBody(
['grant_type' => 'password',
'client_id' => $client->id,
'client_secret' => $client->secret,
'username' => $request->get('email'),
'password' => $request->get('password'),
'user_id' => $userId,
'scope' => implode(' ', $scopes)]
);
} | [
"protected",
"function",
"createRequest",
"(",
"$",
"client",
",",
"$",
"userId",
",",
"$",
"request",
",",
"array",
"$",
"scopes",
")",
"{",
"return",
"(",
"new",
"ServerRequest",
")",
"->",
"withParsedBody",
"(",
"[",
"'grant_type'",
"=>",
"'password'",
... | Create a request instance for the given client.
@param \Laravel\Passport\Client $client
@param mixed $userId
@param array $scopes
@return \Zend\Diactoros\ServerRequest | [
"Create",
"a",
"request",
"instance",
"for",
"the",
"given",
"client",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Api/Controllers/LoginController.php#L50-L61 | train |
avored/framework | src/Product/Controllers/OrderStatusController.php | OrderStatusController.index | public function index()
{
$orderStateGrid = new OrderStatusDataGrid($this->repository->query());
return view('avored-framework::product.order-status.index')->with('dataGrid', $orderStateGrid->dataGrid);
} | php | public function index()
{
$orderStateGrid = new OrderStatusDataGrid($this->repository->query());
return view('avored-framework::product.order-status.index')->with('dataGrid', $orderStateGrid->dataGrid);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"orderStateGrid",
"=",
"new",
"OrderStatusDataGrid",
"(",
"$",
"this",
"->",
"repository",
"->",
"query",
"(",
")",
")",
";",
"return",
"view",
"(",
"'avored-framework::product.order-status.index'",
")",
"->",
... | Display a listing of the OrderStatus.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"OrderStatus",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Product/Controllers/OrderStatusController.php#L35-L40 | train |
avored/framework | database/migrations/2017_03_29_000000_avored_framework_schema.php | AvoredFrameworkSchema.down | public function down()
{
Schema::disableForeignKeyConstraints();
Schema::dropIfExists('order_product_variations');
Schema::dropIfExists('product_variations');
Schema::dropIfExists('product_attribute_integer_values');
Schema::dropIfExists('attribute_dropdown_option_translations');
Schema::dropIfExists('attribute_dropdown_options');
Schema::dropIfExists('attribute_product');
Schema::dropIfExists('product_property');
Schema::dropIfExists('product_property_boolean_values');
Schema::dropIfExists('product_property_text_values');
Schema::dropIfExists('product_property_decimal_values');
Schema::dropIfExists('product_property_integer_values');
Schema::dropIfExists('product_property_varchar_values');
Schema::dropIfExists('product_property_datetime_values');
Schema::dropIfExists('property_dropdown_options');
Schema::dropIfExists('property_translations');
Schema::dropIfExists('properties');
Schema::dropIfExists('category_filters');
Schema::dropIfExists('category_product');
Schema::dropIfExists('product_images');
Schema::dropIfExists('product_prices');
Schema::dropIfExists('category_translations');
Schema::dropIfExists('attribute_translations');
Schema::dropIfExists('attributes');
Schema::dropIfExists('order_return_products');
Schema::dropIfExists('order_return_requests');
Schema::dropIfExists('product_order');
Schema::dropIfExists('order_product');
Schema::dropIfExists('order_histories');
Schema::dropIfExists('orders');
Schema::dropIfExists('order_statuses');
Schema::dropIfExists('product_downloadable_urls');
Schema::dropIfExists('menu_groups');
Schema::dropIfExists('menus');
Schema::dropIfExists('products');
Schema::dropIfExists('categories');
Schema::dropIfExists('oauth_personal_access_clients');
Schema::dropIfExists('oauth_clients');
Schema::dropIfExists('oauth_refresh_tokens');
Schema::dropIfExists('oauth_access_tokens');
Schema::dropIfExists('oauth_auth_codes');
Schema::dropIfExists('admin_password_resets');
Schema::dropIfExists('admin_users');
Schema::dropIfExists('password_resets');
Schema::dropIfExists('user_user_group');
Schema::dropIfExists('user_groups');
Schema::dropIfExists('users');
Schema::dropIfExists('addresses');
Schema::dropIfExists('configurations');
Schema::dropIfExists('tax_rates');
Schema::dropIfExists('tax_groups');
Schema::dropIfExists('site_currencies');
Schema::dropIfExists('pages');
Schema::dropIfExists('wishlists');
Schema::dropIfExists('permission_role');
Schema::dropIfExists('permissions');
Schema::dropIfExists('roles');
Schema::dropIfExists('states');
Schema::dropIfExists('countries');
Schema::dropIfExists('languages');
Schema::enableForeignKeyConstraints();
} | php | public function down()
{
Schema::disableForeignKeyConstraints();
Schema::dropIfExists('order_product_variations');
Schema::dropIfExists('product_variations');
Schema::dropIfExists('product_attribute_integer_values');
Schema::dropIfExists('attribute_dropdown_option_translations');
Schema::dropIfExists('attribute_dropdown_options');
Schema::dropIfExists('attribute_product');
Schema::dropIfExists('product_property');
Schema::dropIfExists('product_property_boolean_values');
Schema::dropIfExists('product_property_text_values');
Schema::dropIfExists('product_property_decimal_values');
Schema::dropIfExists('product_property_integer_values');
Schema::dropIfExists('product_property_varchar_values');
Schema::dropIfExists('product_property_datetime_values');
Schema::dropIfExists('property_dropdown_options');
Schema::dropIfExists('property_translations');
Schema::dropIfExists('properties');
Schema::dropIfExists('category_filters');
Schema::dropIfExists('category_product');
Schema::dropIfExists('product_images');
Schema::dropIfExists('product_prices');
Schema::dropIfExists('category_translations');
Schema::dropIfExists('attribute_translations');
Schema::dropIfExists('attributes');
Schema::dropIfExists('order_return_products');
Schema::dropIfExists('order_return_requests');
Schema::dropIfExists('product_order');
Schema::dropIfExists('order_product');
Schema::dropIfExists('order_histories');
Schema::dropIfExists('orders');
Schema::dropIfExists('order_statuses');
Schema::dropIfExists('product_downloadable_urls');
Schema::dropIfExists('menu_groups');
Schema::dropIfExists('menus');
Schema::dropIfExists('products');
Schema::dropIfExists('categories');
Schema::dropIfExists('oauth_personal_access_clients');
Schema::dropIfExists('oauth_clients');
Schema::dropIfExists('oauth_refresh_tokens');
Schema::dropIfExists('oauth_access_tokens');
Schema::dropIfExists('oauth_auth_codes');
Schema::dropIfExists('admin_password_resets');
Schema::dropIfExists('admin_users');
Schema::dropIfExists('password_resets');
Schema::dropIfExists('user_user_group');
Schema::dropIfExists('user_groups');
Schema::dropIfExists('users');
Schema::dropIfExists('addresses');
Schema::dropIfExists('configurations');
Schema::dropIfExists('tax_rates');
Schema::dropIfExists('tax_groups');
Schema::dropIfExists('site_currencies');
Schema::dropIfExists('pages');
Schema::dropIfExists('wishlists');
Schema::dropIfExists('permission_role');
Schema::dropIfExists('permissions');
Schema::dropIfExists('roles');
Schema::dropIfExists('states');
Schema::dropIfExists('countries');
Schema::dropIfExists('languages');
Schema::enableForeignKeyConstraints();
} | [
"public",
"function",
"down",
"(",
")",
"{",
"Schema",
"::",
"disableForeignKeyConstraints",
"(",
")",
";",
"Schema",
"::",
"dropIfExists",
"(",
"'order_product_variations'",
")",
";",
"Schema",
"::",
"dropIfExists",
"(",
"'product_variations'",
")",
";",
"Schema"... | Uninstall the AvoRed Address Module Schema.
@return void | [
"Uninstall",
"the",
"AvoRed",
"Address",
"Module",
"Schema",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/database/migrations/2017_03_29_000000_avored_framework_schema.php#L851-L928 | train |
avored/framework | src/Models/Database/Address.php | Address.getCountryIdAttribute | public function getCountryIdAttribute()
{
if (isset($this->attributes['country_id']) && $this->attributes['country_id'] > 0) {
return $this->attributes['country_id'];
}
$configRepository = app(ConfigurationInterface::class);
$defaultCountry = $configRepository->getValueByKey('user_default_country');
if (isset($defaultCountry)) {
return $defaultCountry;
}
return null;
} | php | public function getCountryIdAttribute()
{
if (isset($this->attributes['country_id']) && $this->attributes['country_id'] > 0) {
return $this->attributes['country_id'];
}
$configRepository = app(ConfigurationInterface::class);
$defaultCountry = $configRepository->getValueByKey('user_default_country');
if (isset($defaultCountry)) {
return $defaultCountry;
}
return null;
} | [
"public",
"function",
"getCountryIdAttribute",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'country_id'",
"]",
")",
"&&",
"$",
"this",
"->",
"attributes",
"[",
"'country_id'",
"]",
">",
"0",
")",
"{",
"return",
"$",
"... | To Check If Country Id is Null then it Returns Default Country ID from Configuration
@return int|null $countryId | [
"To",
"Check",
"If",
"Country",
"Id",
"is",
"Null",
"then",
"it",
"Returns",
"Default",
"Country",
"ID",
"from",
"Configuration"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Database/Address.php#L43-L57 | train |
avored/framework | src/Tabs/TabsMaker.php | TabsMaker.get | public function get($key)
{
$tab = $this->adminTabs->get($key);
if (null == $tab) {
throw new \Exception('Required Tab is missing');
}
return $this->adminTabs->get($key);
} | php | public function get($key)
{
$tab = $this->adminTabs->get($key);
if (null == $tab) {
throw new \Exception('Required Tab is missing');
}
return $this->adminTabs->get($key);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"tab",
"=",
"$",
"this",
"->",
"adminTabs",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"null",
"==",
"$",
"tab",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Required Tab... | Get Tab from Tabs Collection.
@var string
@return \AvoRed\Framework\Tabs\Tab | [
"Get",
"Tab",
"from",
"Tabs",
"Collection",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Tabs/TabsMaker.php#L43-L51 | train |
avored/framework | src/Tabs/TabsMaker.php | TabsMaker.all | public function all($type = 'product')
{
$tabs = $this->adminTabs->filter(function ($item, $key) use ($type) {
if ($item->type() == $type) {
return true;
}
});
return $tabs;
} | php | public function all($type = 'product')
{
$tabs = $this->adminTabs->filter(function ($item, $key) use ($type) {
if ($item->type() == $type) {
return true;
}
});
return $tabs;
} | [
"public",
"function",
"all",
"(",
"$",
"type",
"=",
"'product'",
")",
"{",
"$",
"tabs",
"=",
"$",
"this",
"->",
"adminTabs",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
",",
"$",
"key",
")",
"use",
"(",
"$",
"type",
")",
"{",
"if",
"(",
... | Return all registered Tab with Specified Type.
@var string
@return \Illuminate\Support\Collection | [
"Return",
"all",
"registered",
"Tab",
"with",
"Specified",
"Type",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Tabs/TabsMaker.php#L59-L68 | train |
avored/framework | src/Models/Repository/CategoryFilterRepository.php | CategoryFilterRepository.saveFilter | public function saveFilter($categoryId, $filterId, $type)
{
$filterModel = CategoryFilter::whereCategoryId($categoryId)
->whereFilterId($filterId)
->whereType('PROPERTY')->first();
if (null === $filterModel) {
CategoryFilter::create([
'category_id' => $categoryId,
'filter_id' => $filterId,
'type' => 'PROPERTY'
]);
}
} | php | public function saveFilter($categoryId, $filterId, $type)
{
$filterModel = CategoryFilter::whereCategoryId($categoryId)
->whereFilterId($filterId)
->whereType('PROPERTY')->first();
if (null === $filterModel) {
CategoryFilter::create([
'category_id' => $categoryId,
'filter_id' => $filterId,
'type' => 'PROPERTY'
]);
}
} | [
"public",
"function",
"saveFilter",
"(",
"$",
"categoryId",
",",
"$",
"filterId",
",",
"$",
"type",
")",
"{",
"$",
"filterModel",
"=",
"CategoryFilter",
"::",
"whereCategoryId",
"(",
"$",
"categoryId",
")",
"->",
"whereFilterId",
"(",
"$",
"filterId",
")",
... | Save Categoy Filter
@param integer $categoryId
@param integer $filterId
@param string $type
@return \AvoRed\Framework\Models\Database\CategoryFilter | [
"Save",
"Categoy",
"Filter"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Models/Repository/CategoryFilterRepository.php#L38-L50 | train |
avored/framework | src/Permission/Manager.php | Manager.add | public function add($key, $callable = null)
{
if (null !== $callable) {
$group = new PermissionGroup($callable);
$group->key($key);
$this->permissions->put($key, $group);
} else {
$group = new PermissionGroup();
$group->key($key);
$this->permissions->put($key, $group);
}
return $group;
} | php | public function add($key, $callable = null)
{
if (null !== $callable) {
$group = new PermissionGroup($callable);
$group->key($key);
$this->permissions->put($key, $group);
} else {
$group = new PermissionGroup();
$group->key($key);
$this->permissions->put($key, $group);
}
return $group;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"callable",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"callable",
")",
"{",
"$",
"group",
"=",
"new",
"PermissionGroup",
"(",
"$",
"callable",
")",
";",
"$",
"group",
"->",
"key",
... | Add Permission into Collection.
@param string $key
@param callable $callable
@return \AvoRed\Framework\Permission\Manager | [
"Add",
"Permission",
"into",
"Collection",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Permission/Manager.php#L38-L52 | train |
avored/framework | src/Permission/Manager.php | Manager.get | public function get($key)
{
if ($this->permissions->has($key)) {
return $this->permissions->get($key);
}
return $collection = Collection::make([]);
} | php | public function get($key)
{
if ($this->permissions->has($key)) {
return $this->permissions->get($key);
}
return $collection = Collection::make([]);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"permissions",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"return",
... | Get Permission Collection if exists or Return Empty Collection.
@param array $item
@return \Illuminate\Support\Collection | [
"Get",
"Permission",
"Collection",
"if",
"exists",
"or",
"Return",
"Empty",
"Collection",
"."
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/Permission/Manager.php#L60-L67 | train |
avored/framework | src/AdminConfiguration/AdminConfigurationGroup.php | AdminConfigurationGroup.addConfiguration | public function addConfiguration($key)
{
$adminConfiguration = new AdminConfiguration();
$adminConfiguration->key($key);
$this->groupList->put($key, $adminConfiguration);
return $adminConfiguration;
} | php | public function addConfiguration($key)
{
$adminConfiguration = new AdminConfiguration();
$adminConfiguration->key($key);
$this->groupList->put($key, $adminConfiguration);
return $adminConfiguration;
} | [
"public",
"function",
"addConfiguration",
"(",
"$",
"key",
")",
"{",
"$",
"adminConfiguration",
"=",
"new",
"AdminConfiguration",
"(",
")",
";",
"$",
"adminConfiguration",
"->",
"key",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"groupList",
"->",
"put",... | Add Configuration to the group list
@param string $key
@return \AvoRed\Framework\AdminConfiguration\AdminConfiguration $adminConfiguration | [
"Add",
"Configuration",
"to",
"the",
"group",
"list"
] | 6f1e4cb7a6126547a9a116026c3f1d9826a91324 | https://github.com/avored/framework/blob/6f1e4cb7a6126547a9a116026c3f1d9826a91324/src/AdminConfiguration/AdminConfigurationGroup.php#L89-L97 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.deleteContactIds | public function deleteContactIds()
{
$conn = $this->getConnection();
$num = $conn->update(
$this->getTable(Schema::EMAIL_CONTACT_TABLE),
['contact_id' => $this->expressionFactory->create(["expression" => 'null'])],
$conn->quoteInto(
'contact_id is ?',
$this->expressionFactory->create(["expression" => 'not null'])
)
);
return $num;
} | php | public function deleteContactIds()
{
$conn = $this->getConnection();
$num = $conn->update(
$this->getTable(Schema::EMAIL_CONTACT_TABLE),
['contact_id' => $this->expressionFactory->create(["expression" => 'null'])],
$conn->quoteInto(
'contact_id is ?',
$this->expressionFactory->create(["expression" => 'not null'])
)
);
return $num;
} | [
"public",
"function",
"deleteContactIds",
"(",
")",
"{",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"num",
"=",
"$",
"conn",
"->",
"update",
"(",
"$",
"this",
"->",
"getTable",
"(",
"Schema",
"::",
"EMAIL_CONTACT_TABLE",
... | Remove all contact_id from the table.
@return int | [
"Remove",
"all",
"contact_id",
"from",
"the",
"table",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L103-L116 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.setContactSuppressedForContactIds | public function setContactSuppressedForContactIds($suppressedContactIds)
{
if (empty($suppressedContactIds)) {
return 0;
}
$conn = $this->getConnection();
//update suppressed for contacts
$updated = $conn->update(
$this->getMainTable(),
['suppressed' => 1],
['email_contact_id IN(?)' => $suppressedContactIds]
);
return $updated;
} | php | public function setContactSuppressedForContactIds($suppressedContactIds)
{
if (empty($suppressedContactIds)) {
return 0;
}
$conn = $this->getConnection();
//update suppressed for contacts
$updated = $conn->update(
$this->getMainTable(),
['suppressed' => 1],
['email_contact_id IN(?)' => $suppressedContactIds]
);
return $updated;
} | [
"public",
"function",
"setContactSuppressedForContactIds",
"(",
"$",
"suppressedContactIds",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"suppressedContactIds",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")... | Set suppressed for contact ids.
@param array $suppressedContactIds
@return int | [
"Set",
"suppressed",
"for",
"contact",
"ids",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L231-L245 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.updateSubscribers | public function updateSubscribers($emailContactIds)
{
if (empty($emailContactIds)) {
return 0;
}
$write = $this->getConnection();
//update subscribers imported
$updated = $write->update(
$this->getMainTable(),
['subscriber_imported' => 1],
["email_contact_id IN (?)" => $emailContactIds]
);
return $updated;
} | php | public function updateSubscribers($emailContactIds)
{
if (empty($emailContactIds)) {
return 0;
}
$write = $this->getConnection();
//update subscribers imported
$updated = $write->update(
$this->getMainTable(),
['subscriber_imported' => 1],
["email_contact_id IN (?)" => $emailContactIds]
);
return $updated;
} | [
"public",
"function",
"updateSubscribers",
"(",
"$",
"emailContactIds",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"emailContactIds",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"write",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"//update sub... | Update subscriber imported.
@param array $emailContactIds
@return int | [
"Update",
"subscriber",
"imported",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L253-L267 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.getSalesDataForSubscribersWithOrderStatusesAndBrand | public function getSalesDataForSubscribersWithOrderStatusesAndBrand($emails, $websiteId)
{
$orderStatuses = $this->config->getWebsiteConfig(
Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
$websiteId
);
$orderStatuses = explode(',', $orderStatuses);
$orderCollection = $this->orderCollectionFactory->create()
->addFieldToSelect(['customer_email'])
->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
->addFieldToFilter('customer_email', ['in' => $emails]);
$columns = $this->buildCollectionColumns();
$orderCollection->getSelect()
->columns($columns)
->group('customer_email');
if (! empty($orderStatuses)) {
$orderCollection->getSelect()->where('status in (?)', $orderStatuses);
}
$orderArray = [];
foreach ($orderCollection as $item) {
$orderArray[$item->getCustomerEmail()] = $item->toArray(
[
'total_spend',
'number_of_orders',
'average_order_value',
'last_order_date',
'first_order_id',
'last_order_id',
'last_increment_id',
'product_id_for_first_brand',
'product_id_for_last_brand',
'week_day',
'month_day',
'product_id_for_most_sold_product'
]
);
}
return $orderArray;
} | php | public function getSalesDataForSubscribersWithOrderStatusesAndBrand($emails, $websiteId)
{
$orderStatuses = $this->config->getWebsiteConfig(
Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
$websiteId
);
$orderStatuses = explode(',', $orderStatuses);
$orderCollection = $this->orderCollectionFactory->create()
->addFieldToSelect(['customer_email'])
->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
->addFieldToFilter('customer_email', ['in' => $emails]);
$columns = $this->buildCollectionColumns();
$orderCollection->getSelect()
->columns($columns)
->group('customer_email');
if (! empty($orderStatuses)) {
$orderCollection->getSelect()->where('status in (?)', $orderStatuses);
}
$orderArray = [];
foreach ($orderCollection as $item) {
$orderArray[$item->getCustomerEmail()] = $item->toArray(
[
'total_spend',
'number_of_orders',
'average_order_value',
'last_order_date',
'first_order_id',
'last_order_id',
'last_increment_id',
'product_id_for_first_brand',
'product_id_for_last_brand',
'week_day',
'month_day',
'product_id_for_most_sold_product'
]
);
}
return $orderArray;
} | [
"public",
"function",
"getSalesDataForSubscribersWithOrderStatusesAndBrand",
"(",
"$",
"emails",
",",
"$",
"websiteId",
")",
"{",
"$",
"orderStatuses",
"=",
"$",
"this",
"->",
"config",
"->",
"getWebsiteConfig",
"(",
"Config",
"::",
"XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_... | Get collection for subscribers by emails.
@param array $emails
@param int $websiteId
@return array | [
"Get",
"collection",
"for",
"subscribers",
"by",
"emails",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L277-L322 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.getSalesDataForCustomersWithOrderStatusesAndBrand | public function getSalesDataForCustomersWithOrderStatusesAndBrand($customerIds, $statuses)
{
$orderCollection = $this->orderCollectionFactory->create();
$salesOrder = $orderCollection->getTable('sales_order');
$salesOrderGrid = $orderCollection->getTable('sales_order_grid');
$salesOrderItem = $orderCollection->getTable('sales_order_item');
$orderCollection->addFieldToSelect(['customer_id'])
->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
->addFieldToFilter('customer_id', ['in' => $customerIds]);
$columnData = $this->buildColumnData($salesOrderGrid, $salesOrder, $salesOrderItem);
$orderCollection->getSelect()
->columns($columnData)
->group('customer_id');
if (! empty($statuses)) {
$orderCollection->getSelect()->where('status in (?)', $statuses);
}
$orderArray = [];
foreach ($orderCollection as $item) {
$orderArray[$item->getCustomerId()] = $item->toArray(
[
'total_spend',
'number_of_orders',
'average_order_value',
'last_order_date',
'first_order_id',
'last_order_id',
'last_increment_id',
'product_id_for_first_brand',
'product_id_for_last_brand',
'week_day',
'month_day',
'product_id_for_most_sold_product'
]
);
}
return $this->getCollectionWithLastQuoteId($customerIds, $orderArray);
} | php | public function getSalesDataForCustomersWithOrderStatusesAndBrand($customerIds, $statuses)
{
$orderCollection = $this->orderCollectionFactory->create();
$salesOrder = $orderCollection->getTable('sales_order');
$salesOrderGrid = $orderCollection->getTable('sales_order_grid');
$salesOrderItem = $orderCollection->getTable('sales_order_item');
$orderCollection->addFieldToSelect(['customer_id'])
->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
->addFieldToFilter('customer_id', ['in' => $customerIds]);
$columnData = $this->buildColumnData($salesOrderGrid, $salesOrder, $salesOrderItem);
$orderCollection->getSelect()
->columns($columnData)
->group('customer_id');
if (! empty($statuses)) {
$orderCollection->getSelect()->where('status in (?)', $statuses);
}
$orderArray = [];
foreach ($orderCollection as $item) {
$orderArray[$item->getCustomerId()] = $item->toArray(
[
'total_spend',
'number_of_orders',
'average_order_value',
'last_order_date',
'first_order_id',
'last_order_id',
'last_increment_id',
'product_id_for_first_brand',
'product_id_for_last_brand',
'week_day',
'month_day',
'product_id_for_most_sold_product'
]
);
}
return $this->getCollectionWithLastQuoteId($customerIds, $orderArray);
} | [
"public",
"function",
"getSalesDataForCustomersWithOrderStatusesAndBrand",
"(",
"$",
"customerIds",
",",
"$",
"statuses",
")",
"{",
"$",
"orderCollection",
"=",
"$",
"this",
"->",
"orderCollectionFactory",
"->",
"create",
"(",
")",
";",
"$",
"salesOrder",
"=",
"$"... | Customer collection with all data ready for export.
@param array $customerIds
@param array $statuses
@return array
@throws \Magento\Framework\Exception\LocalizedException | [
"Customer",
"collection",
"with",
"all",
"data",
"ready",
"for",
"export",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L542-L585 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.getDateLastCronRun | public function getDateLastCronRun($cronJob)
{
$collection = $this->schelduleFactory->create()
->getCollection()
->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_SUCCESS)
->addFieldToFilter('job_code', $cronJob);
//limit and order the results
$collection->getSelect()
->limit(1)
->order('executed_at DESC');
if ($collection->getSize() == 0) {
return false;
}
$executedAt = $collection->getFirstItem()->getExecutedAt();
return $executedAt;
} | php | public function getDateLastCronRun($cronJob)
{
$collection = $this->schelduleFactory->create()
->getCollection()
->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_SUCCESS)
->addFieldToFilter('job_code', $cronJob);
//limit and order the results
$collection->getSelect()
->limit(1)
->order('executed_at DESC');
if ($collection->getSize() == 0) {
return false;
}
$executedAt = $collection->getFirstItem()->getExecutedAt();
return $executedAt;
} | [
"public",
"function",
"getDateLastCronRun",
"(",
"$",
"cronJob",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"schelduleFactory",
"->",
"create",
"(",
")",
"->",
"getCollection",
"(",
")",
"->",
"addFieldToFilter",
"(",
"'status'",
",",
"\\",
"Magent... | Get last cron ran date.
@param string $cronJob
@return boolean|string | [
"Get",
"last",
"cron",
"ran",
"date",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L861-L878 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Contact.php | Contact.updateNotImportedByCustomerIds | public function updateNotImportedByCustomerIds($customerIds)
{
$this->getConnection()->update(
$this->getMainTable(),
['email_imported' => $this->expressionFactory->create(["expression" => 'null'])],
["customer_id IN (?)" => $customerIds]
);
} | php | public function updateNotImportedByCustomerIds($customerIds)
{
$this->getConnection()->update(
$this->getMainTable(),
['email_imported' => $this->expressionFactory->create(["expression" => 'null'])],
["customer_id IN (?)" => $customerIds]
);
} | [
"public",
"function",
"updateNotImportedByCustomerIds",
"(",
"$",
"customerIds",
")",
"{",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"update",
"(",
"$",
"this",
"->",
"getMainTable",
"(",
")",
",",
"[",
"'email_imported'",
"=>",
"$",
"this",
"->",
... | Update contacts to re-import by customer ids
@param array $customerIds | [
"Update",
"contacts",
"to",
"re",
"-",
"import",
"by",
"customer",
"ids"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Contact.php#L885-L892 | train |
dotmailer/dotmailer-magento2-extension | Observer/Customer/ReviewSaveAutomation.php | ReviewSaveAutomation.registerReview | private function registerReview($review)
{
try {
$reviewModel = $this->reviewFactory->create();
$reviewModel->setReviewId($review->getReviewId())
->setCustomerId($review->getCustomerId())
->setStoreId($review->getStoreId());
$this->reviewResource->save($reviewModel);
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
} | php | private function registerReview($review)
{
try {
$reviewModel = $this->reviewFactory->create();
$reviewModel->setReviewId($review->getReviewId())
->setCustomerId($review->getCustomerId())
->setStoreId($review->getStoreId());
$this->reviewResource->save($reviewModel);
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
} | [
"private",
"function",
"registerReview",
"(",
"$",
"review",
")",
"{",
"try",
"{",
"$",
"reviewModel",
"=",
"$",
"this",
"->",
"reviewFactory",
"->",
"create",
"(",
")",
";",
"$",
"reviewModel",
"->",
"setReviewId",
"(",
"$",
"review",
"->",
"getReviewId",... | Register review.
@param mixed $review
@return null | [
"Register",
"review",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Observer/Customer/ReviewSaveAutomation.php#L136-L147 | train |
dotmailer/dotmailer-magento2-extension | Model/Sales/Order.php | Order.createReviewCampaigns | public function createReviewCampaigns()
{
$this->searchOrdersForReview();
foreach ($this->reviewCollection as $websiteId => $collection) {
$this->registerCampaign($collection, $websiteId);
}
} | php | public function createReviewCampaigns()
{
$this->searchOrdersForReview();
foreach ($this->reviewCollection as $websiteId => $collection) {
$this->registerCampaign($collection, $websiteId);
}
} | [
"public",
"function",
"createReviewCampaigns",
"(",
")",
"{",
"$",
"this",
"->",
"searchOrdersForReview",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"reviewCollection",
"as",
"$",
"websiteId",
"=>",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"r... | Create review campaigns
@return null | [
"Create",
"review",
"campaigns"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sales/Order.php#L101-L108 | train |
dotmailer/dotmailer-magento2-extension | Model/Sales/Order.php | Order.registerCampaign | public function registerCampaign($collection, $websiteId)
{
//review campaign id
$campaignId = $this->helper->getCampaign($websiteId);
if ($campaignId) {
foreach ($collection as $order) {
$this->helper->log(
'-- Order Review: ' . $order->getIncrementId()
. ' Campaign Id: ' . $campaignId
);
try {
$emailCampaign = $this->campaignFactory->create()
->setEmail($order->getCustomerEmail())
->setStoreId($order->getStoreId())
->setCampaignId($campaignId)
->setEventName('Order Review')
->setCreatedAt($this->dateTime->formatDate(true))
->setOrderIncrementId($order->getIncrementId())
->setQuoteId($order->getQuoteId());
if ($order->getCustomerId()) {
$emailCampaign->setCustomerId($order->getCustomerId());
}
$this->campaignResource->saveItem($emailCampaign);
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
}
}
} | php | public function registerCampaign($collection, $websiteId)
{
//review campaign id
$campaignId = $this->helper->getCampaign($websiteId);
if ($campaignId) {
foreach ($collection as $order) {
$this->helper->log(
'-- Order Review: ' . $order->getIncrementId()
. ' Campaign Id: ' . $campaignId
);
try {
$emailCampaign = $this->campaignFactory->create()
->setEmail($order->getCustomerEmail())
->setStoreId($order->getStoreId())
->setCampaignId($campaignId)
->setEventName('Order Review')
->setCreatedAt($this->dateTime->formatDate(true))
->setOrderIncrementId($order->getIncrementId())
->setQuoteId($order->getQuoteId());
if ($order->getCustomerId()) {
$emailCampaign->setCustomerId($order->getCustomerId());
}
$this->campaignResource->saveItem($emailCampaign);
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
}
}
} | [
"public",
"function",
"registerCampaign",
"(",
"$",
"collection",
",",
"$",
"websiteId",
")",
"{",
"//review campaign id",
"$",
"campaignId",
"=",
"$",
"this",
"->",
"helper",
"->",
"getCampaign",
"(",
"$",
"websiteId",
")",
";",
"if",
"(",
"$",
"campaignId"... | Register review campaign.
@param \Magento\Sales\Model\ResourceModel\Order\Collection $collection
@param int $websiteId
@return null | [
"Register",
"review",
"campaign",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sales/Order.php#L118-L149 | train |
dotmailer/dotmailer-magento2-extension | Model/Sales/Order.php | Order.searchOrdersForReview | public function searchOrdersForReview()
{
$websites = $this->helper->getwebsites(true);
foreach ($websites as $website) {
$apiEnabled = $this->helper->isEnabled($website);
if ($apiEnabled
&& $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_REVIEWS_ENABLED,
$website
)
&& $this->helper->getOrderStatus($website)
&& $this->helper->getDelay($website)
) {
$storeIds = $website->getStoreIds();
if (empty($storeIds)) {
continue;
}
$orderStatusFromConfig = $this->helper->getOrderStatus(
$website
);
$delayInDays = $this->helper->getDelay(
$website
);
$campaignCollection = $this->campaignCollection->create()
->getCollectionByEvent('Order Review');
$campaignOrderIds = $campaignCollection->getColumnValues(
'order_increment_id'
);
$fromTime = new \DateTime('now', new \DateTimezone('UTC'));
$interval = $this->dateIntervalFactory->create(
['interval_spec' => sprintf('P%sD', $delayInDays)]
);
$fromTime->sub($interval);
$toTime = clone $fromTime;
$fromTime->sub($this->dateIntervalFactory->create(['interval_spec' => 'PT2H']));
$fromDate = $fromTime->format('Y-m-d H:i:s');
$toDate = $toTime->format('Y-m-d H:i:s');
$created = ['from' => $fromDate, 'to' => $toDate, 'date' => true];
$collection = $this->orderCollection->create()
->getSalesCollectionForReviews(
$orderStatusFromConfig,
$created,
$website,
$campaignOrderIds
);
//process rules on collection
$collection = $this->rulesFactory->create()
->process(
$collection,
\Dotdigitalgroup\Email\Model\Rules::REVIEW,
$website->getId()
);
if ($collection->getSize()) {
$this->reviewCollection[$website->getId()] = $collection;
}
}
}
} | php | public function searchOrdersForReview()
{
$websites = $this->helper->getwebsites(true);
foreach ($websites as $website) {
$apiEnabled = $this->helper->isEnabled($website);
if ($apiEnabled
&& $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_REVIEWS_ENABLED,
$website
)
&& $this->helper->getOrderStatus($website)
&& $this->helper->getDelay($website)
) {
$storeIds = $website->getStoreIds();
if (empty($storeIds)) {
continue;
}
$orderStatusFromConfig = $this->helper->getOrderStatus(
$website
);
$delayInDays = $this->helper->getDelay(
$website
);
$campaignCollection = $this->campaignCollection->create()
->getCollectionByEvent('Order Review');
$campaignOrderIds = $campaignCollection->getColumnValues(
'order_increment_id'
);
$fromTime = new \DateTime('now', new \DateTimezone('UTC'));
$interval = $this->dateIntervalFactory->create(
['interval_spec' => sprintf('P%sD', $delayInDays)]
);
$fromTime->sub($interval);
$toTime = clone $fromTime;
$fromTime->sub($this->dateIntervalFactory->create(['interval_spec' => 'PT2H']));
$fromDate = $fromTime->format('Y-m-d H:i:s');
$toDate = $toTime->format('Y-m-d H:i:s');
$created = ['from' => $fromDate, 'to' => $toDate, 'date' => true];
$collection = $this->orderCollection->create()
->getSalesCollectionForReviews(
$orderStatusFromConfig,
$created,
$website,
$campaignOrderIds
);
//process rules on collection
$collection = $this->rulesFactory->create()
->process(
$collection,
\Dotdigitalgroup\Email\Model\Rules::REVIEW,
$website->getId()
);
if ($collection->getSize()) {
$this->reviewCollection[$website->getId()] = $collection;
}
}
}
} | [
"public",
"function",
"searchOrdersForReview",
"(",
")",
"{",
"$",
"websites",
"=",
"$",
"this",
"->",
"helper",
"->",
"getwebsites",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"websites",
"as",
"$",
"website",
")",
"{",
"$",
"apiEnabled",
"=",
"$",
"... | Search for orders to review per website.
@return null | [
"Search",
"for",
"orders",
"to",
"review",
"per",
"website",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sales/Order.php#L156-L221 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Consent.php | Consent.deleteConsentByEmails | public function deleteConsentByEmails($emails)
{
if (empty($emails)) {
return [];
}
$collection = $this->consentCollectionFactory->create();
$collection->getSelect()
->joinInner(
['c' => $this->getTable(Schema::EMAIL_CONTACT_TABLE)],
"c.email_contact_id = main_table.email_contact_id",
[]
);
$collection->addFieldToFilter('c.email', ['in' => $emails]);
return $collection->walk('delete');
} | php | public function deleteConsentByEmails($emails)
{
if (empty($emails)) {
return [];
}
$collection = $this->consentCollectionFactory->create();
$collection->getSelect()
->joinInner(
['c' => $this->getTable(Schema::EMAIL_CONTACT_TABLE)],
"c.email_contact_id = main_table.email_contact_id",
[]
);
$collection->addFieldToFilter('c.email', ['in' => $emails]);
return $collection->walk('delete');
} | [
"public",
"function",
"deleteConsentByEmails",
"(",
"$",
"emails",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"emails",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"collection",
"=",
"$",
"this",
"->",
"consentCollectionFactory",
"->",
"create",
"(",
... | Delete Consent for contact.
@param array $emails
@return array | [
"Delete",
"Consent",
"for",
"contact",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Consent.php#L39-L55 | train |
dotmailer/dotmailer-magento2-extension | Block/Recommended/Wishlistproducts.php | Wishlistproducts._getWishlist | public function _getWishlist()
{
$customerId = (int) $this->getRequest()->getParam('customer_id');
if (!$customerId) {
return [];
}
$customer = $this->customerFactory->create();
$this->customerResource->load($customer, $customerId);
if (! $customer->getId()) {
return [];
}
return $this->wishlist->getWishlistsForCustomer($customerId);
} | php | public function _getWishlist()
{
$customerId = (int) $this->getRequest()->getParam('customer_id');
if (!$customerId) {
return [];
}
$customer = $this->customerFactory->create();
$this->customerResource->load($customer, $customerId);
if (! $customer->getId()) {
return [];
}
return $this->wishlist->getWishlistsForCustomer($customerId);
} | [
"public",
"function",
"_getWishlist",
"(",
")",
"{",
"$",
"customerId",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'customer_id'",
")",
";",
"if",
"(",
"!",
"$",
"customerId",
")",
"{",
"return",
"[",
"]"... | Get wishlist for customer.
@return array|bool | [
"Get",
"wishlist",
"for",
"customer",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Block/Recommended/Wishlistproducts.php#L103-L117 | train |
dotmailer/dotmailer-magento2-extension | Block/Recommended/Wishlistproducts.php | Wishlistproducts.addRecommendedProducts | private function addRecommendedProducts(
&$productsToDisplayCounter,
$limit,
$maxPerChild,
$recommendedProducts,
&$productsToDisplay,
&$product
) {
$i = 0;
foreach ($recommendedProducts as $product) {
//check if still exists
if ($product->getId() && $productsToDisplayCounter < $limit
&& $i <= $maxPerChild
&& $product->isSaleable()
&& !$product->getParentId()
) {
//we have a product to display
$productsToDisplay[$product->getId()] = $product;
$i++;
$productsToDisplayCounter++;
}
}
} | php | private function addRecommendedProducts(
&$productsToDisplayCounter,
$limit,
$maxPerChild,
$recommendedProducts,
&$productsToDisplay,
&$product
) {
$i = 0;
foreach ($recommendedProducts as $product) {
//check if still exists
if ($product->getId() && $productsToDisplayCounter < $limit
&& $i <= $maxPerChild
&& $product->isSaleable()
&& !$product->getParentId()
) {
//we have a product to display
$productsToDisplay[$product->getId()] = $product;
$i++;
$productsToDisplayCounter++;
}
}
} | [
"private",
"function",
"addRecommendedProducts",
"(",
"&",
"$",
"productsToDisplayCounter",
",",
"$",
"limit",
",",
"$",
"maxPerChild",
",",
"$",
"recommendedProducts",
",",
"&",
"$",
"productsToDisplay",
",",
"&",
"$",
"product",
")",
"{",
"$",
"i",
"=",
"0... | Add recommended products
@param int $productsToDisplayCounter
@param int $limit
@param int $maxPerChild
@param array $recommendedProducts
@param array $productsToDisplay
@param \Magento\Catalog\Model\Product $product
@return null | [
"Add",
"recommended",
"products"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Block/Recommended/Wishlistproducts.php#L231-L254 | train |
dotmailer/dotmailer-magento2-extension | Block/Recommended/Wishlistproducts.php | Wishlistproducts.fillProductsToDisplay | private function fillProductsToDisplay($productsToDisplay, &$productsToDisplayCounter, $limit)
{
$fallbackIds = $this->recommnededHelper->getFallbackIds();
$productCollection = $this->catalog->getProductCollectionFromIds($fallbackIds);
foreach ($productCollection as $product) {
if ($product->isSaleable()) {
$productsToDisplay[$product->getId()] = $product;
$productsToDisplayCounter++;
}
//stop the limit was reached
if ($productsToDisplayCounter == $limit) {
break;
}
}
return $productsToDisplay;
} | php | private function fillProductsToDisplay($productsToDisplay, &$productsToDisplayCounter, $limit)
{
$fallbackIds = $this->recommnededHelper->getFallbackIds();
$productCollection = $this->catalog->getProductCollectionFromIds($fallbackIds);
foreach ($productCollection as $product) {
if ($product->isSaleable()) {
$productsToDisplay[$product->getId()] = $product;
$productsToDisplayCounter++;
}
//stop the limit was reached
if ($productsToDisplayCounter == $limit) {
break;
}
}
return $productsToDisplay;
} | [
"private",
"function",
"fillProductsToDisplay",
"(",
"$",
"productsToDisplay",
",",
"&",
"$",
"productsToDisplayCounter",
",",
"$",
"limit",
")",
"{",
"$",
"fallbackIds",
"=",
"$",
"this",
"->",
"recommnededHelper",
"->",
"getFallbackIds",
"(",
")",
";",
"$",
... | Fill products to display
@param array $productsToDisplay
@param int $productsToDisplayCounter
@param int $limit
@return array | [
"Fill",
"products",
"to",
"display"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Block/Recommended/Wishlistproducts.php#L265-L282 | train |
dotmailer/dotmailer-magento2-extension | Block/Recommended/Wishlistproducts.php | Wishlistproducts.getRecommendedProduct | private function getRecommendedProduct($productModel, $mode)
{
//array of products to display
$products = [];
switch ($mode) {
case 'related':
$products = $productModel->getRelatedProductIds();
break;
case 'upsell':
$products = $productModel->getUpSellProductIds();
break;
case 'crosssell':
$products = $productModel->getCrossSellProductIds();
break;
}
return $products;
} | php | private function getRecommendedProduct($productModel, $mode)
{
//array of products to display
$products = [];
switch ($mode) {
case 'related':
$products = $productModel->getRelatedProductIds();
break;
case 'upsell':
$products = $productModel->getUpSellProductIds();
break;
case 'crosssell':
$products = $productModel->getCrossSellProductIds();
break;
}
return $products;
} | [
"private",
"function",
"getRecommendedProduct",
"(",
"$",
"productModel",
",",
"$",
"mode",
")",
"{",
"//array of products to display",
"$",
"products",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"'related'",
":",
"$",
"products",
"=",... | Product related items.
@param \Magento\Catalog\Model\Product $productModel
@param string $mode
@return array | [
"Product",
"related",
"items",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Block/Recommended/Wishlistproducts.php#L292-L309 | train |
dotmailer/dotmailer-magento2-extension | Model/Config/Configuration/Publicdatafields.php | Publicdatafields.getDataFields | public function getDataFields()
{
$website = $this->helper->getWebsite();
$client = $this->helper->getWebsiteApiClient($website);
//grab the datafields request and save to register
$datafields = $client->getDataFields();
return $datafields;
} | php | public function getDataFields()
{
$website = $this->helper->getWebsite();
$client = $this->helper->getWebsiteApiClient($website);
//grab the datafields request and save to register
$datafields = $client->getDataFields();
return $datafields;
} | [
"public",
"function",
"getDataFields",
"(",
")",
"{",
"$",
"website",
"=",
"$",
"this",
"->",
"helper",
"->",
"getWebsite",
"(",
")",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"helper",
"->",
"getWebsiteApiClient",
"(",
"$",
"website",
")",
";",
"//g... | Get data fields.
@return mixed | [
"Get",
"data",
"fields",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Config/Configuration/Publicdatafields.php#L28-L37 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Connector/Ajaxlogcontent.php | Ajaxlogcontent.execute | public function execute()
{
$logFile = $this->getRequest()->getParam('log');
switch ($logFile) {
case "connector":
$header = 'Marketing Automation Log';
break;
case "system":
$header = 'Magento System Log';
break;
case "exception":
$header = 'Magento Exception Log';
break;
case "debug":
$header = 'Magento Debug Log';
break;
default:
$header = 'Marketing Automation Log';
}
$content = nl2br($this->escaper->escapeHtml($this->file->getLogFileContent($logFile)));
$response = [
'content' => $content,
'header' => $header
];
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($response));
} | php | public function execute()
{
$logFile = $this->getRequest()->getParam('log');
switch ($logFile) {
case "connector":
$header = 'Marketing Automation Log';
break;
case "system":
$header = 'Magento System Log';
break;
case "exception":
$header = 'Magento Exception Log';
break;
case "debug":
$header = 'Magento Debug Log';
break;
default:
$header = 'Marketing Automation Log';
}
$content = nl2br($this->escaper->escapeHtml($this->file->getLogFileContent($logFile)));
$response = [
'content' => $content,
'header' => $header
];
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($response));
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"logFile",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'log'",
")",
";",
"switch",
"(",
"$",
"logFile",
")",
"{",
"case",
"\"connector\"",
":",
"$",
"header",
"=",
"'Mar... | Ajax get log file content.
@return null | [
"Ajax",
"get",
"log",
"file",
"content",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Connector/Ajaxlogcontent.php#L54-L79 | train |
dotmailer/dotmailer-magento2-extension | Block/Adminhtml/Config/Createaddressbook.php | Createaddressbook.render | public function render(
\Magento\Framework\Data\Form\Element\AbstractElement $element
) {
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
} | php | public function render(
\Magento\Framework\Data\Form\Element\AbstractElement $element
) {
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
} | [
"public",
"function",
"render",
"(",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"Data",
"\\",
"Form",
"\\",
"Element",
"\\",
"AbstractElement",
"$",
"element",
")",
"{",
"$",
"element",
"->",
"unsScope",
"(",
")",
"->",
"unsCanUseWebsiteValue",
"(",
")",
"-... | Unset some non-related element parameters.
@param \Magento\Framework\Data\Form\Element\AbstractElement $element
@return string | [
"Unset",
"some",
"non",
"-",
"related",
"element",
"parameters",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Block/Adminhtml/Config/Createaddressbook.php#L46-L52 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.resetReviews | public function resetReviews($from = null, $to = null)
{
$conn = $this->getConnection();
if ($from && $to) {
$where = [
'created_at >= ?' => $from . ' 00:00:00',
'created_at <= ?' => $to . ' 23:59:59',
'review_imported is ?' => new \Zend_Db_Expr('not null')
];
} else {
$where = $conn->quoteInto(
'review_imported is ?',
new \Zend_Db_Expr('not null')
);
}
$num = $conn->update(
$this->getTable(Schema::EMAIL_REVIEW_TABLE),
['review_imported' => new \Zend_Db_Expr('null')],
$where
);
return $num;
} | php | public function resetReviews($from = null, $to = null)
{
$conn = $this->getConnection();
if ($from && $to) {
$where = [
'created_at >= ?' => $from . ' 00:00:00',
'created_at <= ?' => $to . ' 23:59:59',
'review_imported is ?' => new \Zend_Db_Expr('not null')
];
} else {
$where = $conn->quoteInto(
'review_imported is ?',
new \Zend_Db_Expr('not null')
);
}
$num = $conn->update(
$this->getTable(Schema::EMAIL_REVIEW_TABLE),
['review_imported' => new \Zend_Db_Expr('null')],
$where
);
return $num;
} | [
"public",
"function",
"resetReviews",
"(",
"$",
"from",
"=",
"null",
",",
"$",
"to",
"=",
"null",
")",
"{",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"if",
"(",
"$",
"from",
"&&",
"$",
"to",
")",
"{",
"$",
"where",
"=... | Reset the email reviews for re-import.
@param string $from
@param string $to
@return int | [
"Reset",
"the",
"email",
"reviews",
"for",
"re",
"-",
"import",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L114-L136 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.filterItemsForReview | public function filterItemsForReview($items, $customerId, $order)
{
foreach ($items as $key => $item) {
$productId = $item->getProduct()->getId();
$collection = $this->reviewFactory->create()->getCollection()
->addCustomerFilter($customerId)
->addStoreFilter($order->getStoreId())
->addFieldToFilter('main_table.entity_pk_value', $productId);
//remove item if customer has already placed review on this item
if ($collection->getSize()) {
unset($items[$key]);
}
}
return $items;
} | php | public function filterItemsForReview($items, $customerId, $order)
{
foreach ($items as $key => $item) {
$productId = $item->getProduct()->getId();
$collection = $this->reviewFactory->create()->getCollection()
->addCustomerFilter($customerId)
->addStoreFilter($order->getStoreId())
->addFieldToFilter('main_table.entity_pk_value', $productId);
//remove item if customer has already placed review on this item
if ($collection->getSize()) {
unset($items[$key]);
}
}
return $items;
} | [
"public",
"function",
"filterItemsForReview",
"(",
"$",
"items",
",",
"$",
"customerId",
",",
"$",
"order",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"productId",
"=",
"$",
"item",
"->",
"getProduct",
... | Filter items for review.
@param array $items
@param int $customerId
@param \Magento\Sales\Model\Order $order
@return mixed | [
"Filter",
"items",
"for",
"review",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L147-L164 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.getProductCollection | public function getProductCollection($quote)
{
$productIds = [];
$products = [];
$items = $quote->getAllVisibleItems();
//get the product ids for the collection
foreach ($items as $item) {
$productIds[] = $item->getProductId();
}
if (! empty($productIds)) {
$products = $this->productCollection->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id', ['in' => $productIds]);
}
return $products;
} | php | public function getProductCollection($quote)
{
$productIds = [];
$products = [];
$items = $quote->getAllVisibleItems();
//get the product ids for the collection
foreach ($items as $item) {
$productIds[] = $item->getProductId();
}
if (! empty($productIds)) {
$products = $this->productCollection->create()
->addAttributeToSelect('*')
->addFieldToFilter('entity_id', ['in' => $productIds]);
}
return $products;
} | [
"public",
"function",
"getProductCollection",
"(",
"$",
"quote",
")",
"{",
"$",
"productIds",
"=",
"[",
"]",
";",
"$",
"products",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"quote",
"->",
"getAllVisibleItems",
"(",
")",
";",
"//get the product ids for th... | Get product collection from order.
@param \Magento\Quote\Model\Quote $quote
@return array|\Magento\Framework\Data\Collection\AbstractDb | [
"Get",
"product",
"collection",
"from",
"order",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L173-L191 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.getMageReviewsByIds | public function getMageReviewsByIds($ids)
{
$reviews = $this->mageReviewCollection->create()
->addFieldToFilter(
'main_table.review_id',
['in' => $ids]
)
->addFieldToFilter('customer_id', ['notnull' => 'true']);
$reviews->getSelect()
->joinLeft(
['c' => $this->getTable('customer_entity')],
'c.entity_id = customer_id',
['email', 'store_id']
);
return $reviews;
} | php | public function getMageReviewsByIds($ids)
{
$reviews = $this->mageReviewCollection->create()
->addFieldToFilter(
'main_table.review_id',
['in' => $ids]
)
->addFieldToFilter('customer_id', ['notnull' => 'true']);
$reviews->getSelect()
->joinLeft(
['c' => $this->getTable('customer_entity')],
'c.entity_id = customer_id',
['email', 'store_id']
);
return $reviews;
} | [
"public",
"function",
"getMageReviewsByIds",
"(",
"$",
"ids",
")",
"{",
"$",
"reviews",
"=",
"$",
"this",
"->",
"mageReviewCollection",
"->",
"create",
"(",
")",
"->",
"addFieldToFilter",
"(",
"'main_table.review_id'",
",",
"[",
"'in'",
"=>",
"$",
"ids",
"]"... | Get Mage reviews by ids.
@param array $ids
@return \Magento\Review\Model\ResourceModel\Review\Collection | [
"Get",
"Mage",
"reviews",
"by",
"ids",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L223-L240 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.getProductByIdAndStore | public function getProductByIdAndStore($id, $storeId)
{
$product = $this->productFactory->create()
->getCollection()
->addIdFilter($id)
->setStoreId($storeId)
->addAttributeToSelect(
['product_url', 'name', 'store_id', 'small_image']
)
->setPage(1, 1);
return $product->getFirstItem();
} | php | public function getProductByIdAndStore($id, $storeId)
{
$product = $this->productFactory->create()
->getCollection()
->addIdFilter($id)
->setStoreId($storeId)
->addAttributeToSelect(
['product_url', 'name', 'store_id', 'small_image']
)
->setPage(1, 1);
return $product->getFirstItem();
} | [
"public",
"function",
"getProductByIdAndStore",
"(",
"$",
"id",
",",
"$",
"storeId",
")",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"productFactory",
"->",
"create",
"(",
")",
"->",
"getCollection",
"(",
")",
"->",
"addIdFilter",
"(",
"$",
"id",
")",
... | Get product by id and store.
@param int $id
@param int $storeId
@return mixed | [
"Get",
"product",
"by",
"id",
"and",
"store",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L250-L262 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Review.php | Review.getVoteCollectionByReview | public function getVoteCollectionByReview($reviewId)
{
$votesCollection = $this->voteCollection->create()
->setReviewFilter($reviewId);
$votesCollection->getSelect()->join(
['rating' => $this->getTable('rating')],
'rating.rating_id = main_table.rating_id',
['rating_code' => 'rating.rating_code']
);
return $votesCollection;
} | php | public function getVoteCollectionByReview($reviewId)
{
$votesCollection = $this->voteCollection->create()
->setReviewFilter($reviewId);
$votesCollection->getSelect()->join(
['rating' => $this->getTable('rating')],
'rating.rating_id = main_table.rating_id',
['rating_code' => 'rating.rating_code']
);
return $votesCollection;
} | [
"public",
"function",
"getVoteCollectionByReview",
"(",
"$",
"reviewId",
")",
"{",
"$",
"votesCollection",
"=",
"$",
"this",
"->",
"voteCollection",
"->",
"create",
"(",
")",
"->",
"setReviewFilter",
"(",
"$",
"reviewId",
")",
";",
"$",
"votesCollection",
"->"... | Get vote collection by review.
@param int $reviewId
@return mixed | [
"Get",
"vote",
"collection",
"by",
"review",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Review.php#L271-L283 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Connector/Ajaxvalidation.php | Ajaxvalidation.execute | public function execute()
{
$params = $this->getRequest()->getParams();
$apiUsername = $params['api_username'];
$apiPassword = base64_decode($params['api_password']);
//validate api, check against account info.
if ($this->data->isEnabled()) {
$client = $this->data->getWebsiteApiClient();
$result = $client->validate($apiUsername, $apiPassword);
$resonseData['success'] = true;
//validation failed
if (!$result) {
$resonseData['success'] = false;
$resonseData['message'] = 'Authorization has been denied for this request.';
}
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($resonseData));
}
} | php | public function execute()
{
$params = $this->getRequest()->getParams();
$apiUsername = $params['api_username'];
$apiPassword = base64_decode($params['api_password']);
//validate api, check against account info.
if ($this->data->isEnabled()) {
$client = $this->data->getWebsiteApiClient();
$result = $client->validate($apiUsername, $apiPassword);
$resonseData['success'] = true;
//validation failed
if (!$result) {
$resonseData['success'] = false;
$resonseData['message'] = 'Authorization has been denied for this request.';
}
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($resonseData));
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParams",
"(",
")",
";",
"$",
"apiUsername",
"=",
"$",
"params",
"[",
"'api_username'",
"]",
";",
"$",
"apiPassword",
"=",
"base64_d... | Validate api user.
@return void | [
"Validate",
"api",
"user",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Connector/Ajaxvalidation.php#L46-L65 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Order.php | Order.resetOrders | public function resetOrders($from = null, $to = null)
{
$conn = $this->getConnection();
if ($from && $to) {
$where = [
'created_at >= ?' => $from . ' 00:00:00',
'created_at <= ?' => $to . ' 23:59:59',
'email_imported is ?' => new \Zend_Db_Expr('not null')
];
} else {
$where = $conn->quoteInto(
'email_imported is ?',
new \Zend_Db_Expr('not null')
);
}
$num = $conn->update(
$this->getTable(Schema::EMAIL_ORDER_TABLE),
[
'email_imported' => new \Zend_Db_Expr('null'),
'modified' => new \Zend_Db_Expr('null'),
],
$where
);
return $num;
} | php | public function resetOrders($from = null, $to = null)
{
$conn = $this->getConnection();
if ($from && $to) {
$where = [
'created_at >= ?' => $from . ' 00:00:00',
'created_at <= ?' => $to . ' 23:59:59',
'email_imported is ?' => new \Zend_Db_Expr('not null')
];
} else {
$where = $conn->quoteInto(
'email_imported is ?',
new \Zend_Db_Expr('not null')
);
}
$num = $conn->update(
$this->getTable(Schema::EMAIL_ORDER_TABLE),
[
'email_imported' => new \Zend_Db_Expr('null'),
'modified' => new \Zend_Db_Expr('null'),
],
$where
);
return $num;
} | [
"public",
"function",
"resetOrders",
"(",
"$",
"from",
"=",
"null",
",",
"$",
"to",
"=",
"null",
")",
"{",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"if",
"(",
"$",
"from",
"&&",
"$",
"to",
")",
"{",
"$",
"where",
"="... | Reset the email order for re-import.
@param string|null $from
@param string|null $to
@return int | [
"Reset",
"the",
"email",
"order",
"for",
"re",
"-",
"import",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Order.php#L28-L53 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Order.php | Order.setImported | public function setImported($ids)
{
if (empty($ids)) {
return;
}
$connection = $this->getConnection();
$tableName = $this->getTable(Schema::EMAIL_ORDER_TABLE);
$connection->update(
$tableName,
[
'modified' => new \Zend_Db_Expr('null'),
'email_imported' => '1',
'updated_at' => gmdate('Y-m-d H:i:s')
],
["order_id IN (?)" => $ids]
);
} | php | public function setImported($ids)
{
if (empty($ids)) {
return;
}
$connection = $this->getConnection();
$tableName = $this->getTable(Schema::EMAIL_ORDER_TABLE);
$connection->update(
$tableName,
[
'modified' => new \Zend_Db_Expr('null'),
'email_imported' => '1',
'updated_at' => gmdate('Y-m-d H:i:s')
],
["order_id IN (?)" => $ids]
);
} | [
"public",
"function",
"setImported",
"(",
"$",
"ids",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"return",
";",
"}",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"tableName",
"=",
"$",
"this",
... | Mark the connector orders to be imported.
@param array $ids
@return null | [
"Mark",
"the",
"connector",
"orders",
"to",
"be",
"imported",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Order.php#L62-L78 | train |
dotmailer/dotmailer-magento2-extension | Model/SalesRule/DotmailerCouponGenerator.php | DotmailerCouponGenerator.generateCoupon | public function generateCoupon($priceRuleId, $expireDate)
{
$rule = $this->getPriceRule($priceRuleId);
$coupon = $rule->acquireCoupon();
$coupon = $this->setUpCoupon($expireDate, $coupon, $rule);
$this->couponResourceInterface->save($coupon);
return $coupon->getCode();
} | php | public function generateCoupon($priceRuleId, $expireDate)
{
$rule = $this->getPriceRule($priceRuleId);
$coupon = $rule->acquireCoupon();
$coupon = $this->setUpCoupon($expireDate, $coupon, $rule);
$this->couponResourceInterface->save($coupon);
return $coupon->getCode();
} | [
"public",
"function",
"generateCoupon",
"(",
"$",
"priceRuleId",
",",
"$",
"expireDate",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"getPriceRule",
"(",
"$",
"priceRuleId",
")",
";",
"$",
"coupon",
"=",
"$",
"rule",
"->",
"acquireCoupon",
"(",
")",
... | Generate coupon.
@param int $priceRuleId
@param \DateTime $expireDate
@return bool
@throws \Magento\Framework\Exception\LocalizedException | [
"Generate",
"coupon",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/SalesRule/DotmailerCouponGenerator.php#L68-L76 | train |
dotmailer/dotmailer-magento2-extension | Model/Importer.php | Importer.registerQueue | public function registerQueue(
$importType,
$importData,
$importMode,
$websiteId,
$file = false
) {
try {
if (! empty($importData)) {
$importData = $this->serializer->serialize($importData);
}
if ($file) {
$this->setImportFile($file);
}
if ($importData || $file) {
$this->setImportType($importType)
->setImportData($importData)
->setWebsiteId($websiteId)
->setImportMode($importMode);
$this->importerResource->save($this);
return true;
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
if ($this->serializer->jsonError) {
$jle = $this->serializer->jsonError;
$format = "Json error ($jle) for Import type ($importType) / mode ($importMode) for website ($websiteId)";
$this->helper->log($format);
}
return false;
} | php | public function registerQueue(
$importType,
$importData,
$importMode,
$websiteId,
$file = false
) {
try {
if (! empty($importData)) {
$importData = $this->serializer->serialize($importData);
}
if ($file) {
$this->setImportFile($file);
}
if ($importData || $file) {
$this->setImportType($importType)
->setImportData($importData)
->setWebsiteId($websiteId)
->setImportMode($importMode);
$this->importerResource->save($this);
return true;
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
if ($this->serializer->jsonError) {
$jle = $this->serializer->jsonError;
$format = "Json error ($jle) for Import type ($importType) / mode ($importMode) for website ($websiteId)";
$this->helper->log($format);
}
return false;
} | [
"public",
"function",
"registerQueue",
"(",
"$",
"importType",
",",
"$",
"importData",
",",
"$",
"importMode",
",",
"$",
"websiteId",
",",
"$",
"file",
"=",
"false",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"importData",
")",
")",
"{"... | Register import in queue.
@param string $importType
@param array|string|null $importData
@param string $importMode
@param int $websiteId
@param bool $file
@return bool | [
"Register",
"import",
"in",
"queue",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Importer.php#L183-L220 | train |
dotmailer/dotmailer-magento2-extension | Model/Importer.php | Importer.processQueue | public function processQueue()
{
//Set items to 0
$this->totalItems = 0;
//Set bulk sync limit
$this->bulkSyncLimit = 5;
//Set priority
$this->_setPriority();
//Check previous import status
$this->_checkImportStatus();
//Bulk priority. Process group 1 first
foreach ($this->bulkPriority as $bulk) {
if ($this->totalItems < $bulk['limit']) {
$collection = $this->_getQueue(
$bulk['type'],
$bulk['mode'],
$bulk['limit'] - $this->totalItems
);
if ($collection->getSize()) {
$this->totalItems += $collection->getSize();
$bulkModel = $this->objectManager->create($bulk['model']);
$bulkModel->sync($collection);
}
}
}
//reset total items to 0
$this->totalItems = 0;
//Single/Update priority.
foreach ($this->singlePriority as $single) {
if ($this->totalItems < $single['limit']) {
$collection = $this->_getQueue(
$single['type'],
$single['mode'],
$single['limit'] - $this->totalItems
);
if ($collection->getSize()) {
$this->totalItems += $collection->getSize();
$singleModel = $this->objectManager->create(
$single['model']
);
$singleModel->sync($collection);
}
}
}
} | php | public function processQueue()
{
//Set items to 0
$this->totalItems = 0;
//Set bulk sync limit
$this->bulkSyncLimit = 5;
//Set priority
$this->_setPriority();
//Check previous import status
$this->_checkImportStatus();
//Bulk priority. Process group 1 first
foreach ($this->bulkPriority as $bulk) {
if ($this->totalItems < $bulk['limit']) {
$collection = $this->_getQueue(
$bulk['type'],
$bulk['mode'],
$bulk['limit'] - $this->totalItems
);
if ($collection->getSize()) {
$this->totalItems += $collection->getSize();
$bulkModel = $this->objectManager->create($bulk['model']);
$bulkModel->sync($collection);
}
}
}
//reset total items to 0
$this->totalItems = 0;
//Single/Update priority.
foreach ($this->singlePriority as $single) {
if ($this->totalItems < $single['limit']) {
$collection = $this->_getQueue(
$single['type'],
$single['mode'],
$single['limit'] - $this->totalItems
);
if ($collection->getSize()) {
$this->totalItems += $collection->getSize();
$singleModel = $this->objectManager->create(
$single['model']
);
$singleModel->sync($collection);
}
}
}
} | [
"public",
"function",
"processQueue",
"(",
")",
"{",
"//Set items to 0",
"$",
"this",
"->",
"totalItems",
"=",
"0",
";",
"//Set bulk sync limit",
"$",
"this",
"->",
"bulkSyncLimit",
"=",
"5",
";",
"//Set priority",
"$",
"this",
"->",
"_setPriority",
"(",
")",
... | Proccess the data from queue.
@return null | [
"Proccess",
"the",
"data",
"from",
"queue",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Importer.php#L235-L285 | train |
dotmailer/dotmailer-magento2-extension | Model/Importer.php | Importer._checkImportStatus | public function _checkImportStatus()
{
if ($items = $this->_getImportingItems($this->bulkSyncLimit)) {
foreach ($items as $item) {
$websiteId = $item->getWebsiteId();
$client = false;
if ($this->helper->isEnabled($websiteId)) {
$client = $this->helper->getWebsiteApiClient(
$websiteId
);
}
if ($client) {
try {
if ($item->getImportType() == self::IMPORT_TYPE_CONTACT ||
$item->getImportType() == self::IMPORT_TYPE_SUBSCRIBERS ||
$item->getImportType() == self::IMPORT_TYPE_GUEST
) {
$response = $client->getContactsImportByImportId($item->getImportId());
} else {
$response = $client->getContactsTransactionalDataImportByImportId(
$item->getImportId()
);
}
} catch (\Exception $e) {
$item->setMessage($e->getMessage())
->setImportStatus(self::FAILED);
$this->saveItem($item);
continue;
}
$this->processResponse($response, $item, $websiteId);
}
}
}
} | php | public function _checkImportStatus()
{
if ($items = $this->_getImportingItems($this->bulkSyncLimit)) {
foreach ($items as $item) {
$websiteId = $item->getWebsiteId();
$client = false;
if ($this->helper->isEnabled($websiteId)) {
$client = $this->helper->getWebsiteApiClient(
$websiteId
);
}
if ($client) {
try {
if ($item->getImportType() == self::IMPORT_TYPE_CONTACT ||
$item->getImportType() == self::IMPORT_TYPE_SUBSCRIBERS ||
$item->getImportType() == self::IMPORT_TYPE_GUEST
) {
$response = $client->getContactsImportByImportId($item->getImportId());
} else {
$response = $client->getContactsTransactionalDataImportByImportId(
$item->getImportId()
);
}
} catch (\Exception $e) {
$item->setMessage($e->getMessage())
->setImportStatus(self::FAILED);
$this->saveItem($item);
continue;
}
$this->processResponse($response, $item, $websiteId);
}
}
}
} | [
"public",
"function",
"_checkImportStatus",
"(",
")",
"{",
"if",
"(",
"$",
"items",
"=",
"$",
"this",
"->",
"_getImportingItems",
"(",
"$",
"this",
"->",
"bulkSyncLimit",
")",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
... | Check importing status for pending import.
@return null | [
"Check",
"importing",
"status",
"for",
"pending",
"import",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Importer.php#L420-L454 | train |
dotmailer/dotmailer-magento2-extension | Model/Importer.php | Importer._processContactImportReportFaults | public function _processContactImportReportFaults($id, $websiteId)
{
$client = $this->helper->getWebsiteApiClient($websiteId);
$report = $client->getContactImportReportFaults($id);
if ($report) {
$reportData = explode(PHP_EOL, $this->_removeUtf8Bom($report));
//unset header
unset($reportData[0]);
//no data in report
if (! empty($reportData)) {
$contacts = [];
foreach ($reportData as $row) {
$row = explode(',', $row);
//reason
if (in_array($row[0], $this->reasons)) {
//email
$contacts[] = $row[1];
}
}
//unsubscribe from email contact and newsletter subscriber tables
$this->helper->contactResource->unsubscribe($contacts);
}
}
} | php | public function _processContactImportReportFaults($id, $websiteId)
{
$client = $this->helper->getWebsiteApiClient($websiteId);
$report = $client->getContactImportReportFaults($id);
if ($report) {
$reportData = explode(PHP_EOL, $this->_removeUtf8Bom($report));
//unset header
unset($reportData[0]);
//no data in report
if (! empty($reportData)) {
$contacts = [];
foreach ($reportData as $row) {
$row = explode(',', $row);
//reason
if (in_array($row[0], $this->reasons)) {
//email
$contacts[] = $row[1];
}
}
//unsubscribe from email contact and newsletter subscriber tables
$this->helper->contactResource->unsubscribe($contacts);
}
}
} | [
"public",
"function",
"_processContactImportReportFaults",
"(",
"$",
"id",
",",
"$",
"websiteId",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"helper",
"->",
"getWebsiteApiClient",
"(",
"$",
"websiteId",
")",
";",
"$",
"report",
"=",
"$",
"client",
"-... | Get report info for contacts sync.
@param int $id
@param int $websiteId
@throws \Magento\Framework\Exception\LocalizedException
@return null | [
"Get",
"report",
"info",
"for",
"contacts",
"sync",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Importer.php#L558-L583 | train |
dotmailer/dotmailer-magento2-extension | Model/Importer.php | Importer._getQueue | public function _getQueue($importType, $importMode, $limit)
{
return $this->getCollection()
->getQueueByTypeAndMode($importType, $importMode, $limit);
} | php | public function _getQueue($importType, $importMode, $limit)
{
return $this->getCollection()
->getQueueByTypeAndMode($importType, $importMode, $limit);
} | [
"public",
"function",
"_getQueue",
"(",
"$",
"importType",
",",
"$",
"importMode",
",",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
"->",
"getCollection",
"(",
")",
"->",
"getQueueByTypeAndMode",
"(",
"$",
"importType",
",",
"$",
"importMode",
",",
"$",... | Get the imports by type.
@param string $importType
@param string $importMode
@param int $limit
@return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection | [
"Get",
"the",
"imports",
"by",
"type",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Importer.php#L609-L613 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order.setOrderData | public function setOrderData($orderData)
{
$this->id = $orderData->getIncrementId();
$this->email = $orderData->getCustomerEmail();
$this->quoteId = $orderData->getQuoteId();
$this->storeName = $orderData->getStoreName();
$this->purchaseDate = $orderData->getCreatedAt();
$this->deliveryMethod = $orderData->getShippingDescription();
$this->deliveryTotal = (float)number_format(
$orderData->getShippingAmount(),
2,
'.',
''
);
$this->currency = $orderData->getStoreCurrencyCode();
$payment = $orderData->getPayment();
if ($payment) {
if ($payment->getMethod()) {
$methodInstance = $payment->getMethodInstance($payment->getMethod());
if ($methodInstance) {
$this->payment = $methodInstance->getTitle();
}
}
}
$this->couponCode = $orderData->getCouponCode();
/*
* custom order attributes
*/
$website = $this->_storeManager->getStore($orderData->getStore())->getWebsite();
$customAttributes
= $this->helper->getConfigSelectedCustomOrderAttributes(
$website
);
if ($customAttributes) {
$fields = $this->helper->getOrderTableDescription();
$this->custom = [];
foreach ($customAttributes as $customAttribute) {
if (isset($fields[$customAttribute])) {
$field = $fields[$customAttribute];
$value = $this->_getCustomAttributeValue(
$field,
$orderData
);
if ($value) {
$this->_assignCustom($field, $value);
}
}
}
}
/*
* Billing address.
*/
$this->processBillingAddress($orderData);
/*
* Shipping address.
*/
$this->processShippingAddress($orderData);
$syncCustomOption = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS,
$website
);
/*
* Order items.
*/
$this->processOrderItems($orderData, $syncCustomOption);
$this->orderSubtotal = (float)number_format(
$orderData->getData('subtotal'),
2,
'.',
''
);
$this->discountAmount = (float)number_format(
$orderData->getData('discount_amount'),
2,
'.',
''
);
$orderTotal = abs(
$orderData->getData('grand_total') - $orderData->getTotalRefunded()
);
$this->orderTotal = (float)number_format($orderTotal, 2, '.', '');
$this->orderStatus = $orderData->getStatus();
unset($this->_storeManager);
return $this;
} | php | public function setOrderData($orderData)
{
$this->id = $orderData->getIncrementId();
$this->email = $orderData->getCustomerEmail();
$this->quoteId = $orderData->getQuoteId();
$this->storeName = $orderData->getStoreName();
$this->purchaseDate = $orderData->getCreatedAt();
$this->deliveryMethod = $orderData->getShippingDescription();
$this->deliveryTotal = (float)number_format(
$orderData->getShippingAmount(),
2,
'.',
''
);
$this->currency = $orderData->getStoreCurrencyCode();
$payment = $orderData->getPayment();
if ($payment) {
if ($payment->getMethod()) {
$methodInstance = $payment->getMethodInstance($payment->getMethod());
if ($methodInstance) {
$this->payment = $methodInstance->getTitle();
}
}
}
$this->couponCode = $orderData->getCouponCode();
/*
* custom order attributes
*/
$website = $this->_storeManager->getStore($orderData->getStore())->getWebsite();
$customAttributes
= $this->helper->getConfigSelectedCustomOrderAttributes(
$website
);
if ($customAttributes) {
$fields = $this->helper->getOrderTableDescription();
$this->custom = [];
foreach ($customAttributes as $customAttribute) {
if (isset($fields[$customAttribute])) {
$field = $fields[$customAttribute];
$value = $this->_getCustomAttributeValue(
$field,
$orderData
);
if ($value) {
$this->_assignCustom($field, $value);
}
}
}
}
/*
* Billing address.
*/
$this->processBillingAddress($orderData);
/*
* Shipping address.
*/
$this->processShippingAddress($orderData);
$syncCustomOption = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS,
$website
);
/*
* Order items.
*/
$this->processOrderItems($orderData, $syncCustomOption);
$this->orderSubtotal = (float)number_format(
$orderData->getData('subtotal'),
2,
'.',
''
);
$this->discountAmount = (float)number_format(
$orderData->getData('discount_amount'),
2,
'.',
''
);
$orderTotal = abs(
$orderData->getData('grand_total') - $orderData->getTotalRefunded()
);
$this->orderTotal = (float)number_format($orderTotal, 2, '.', '');
$this->orderStatus = $orderData->getStatus();
unset($this->_storeManager);
return $this;
} | [
"public",
"function",
"setOrderData",
"(",
"$",
"orderData",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"orderData",
"->",
"getIncrementId",
"(",
")",
";",
"$",
"this",
"->",
"email",
"=",
"$",
"orderData",
"->",
"getCustomerEmail",
"(",
")",
";",
"$... | Set the order data information.
@param \Magento\Sales\Model\Order $orderData
@return $this | [
"Set",
"the",
"order",
"data",
"information",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L185-L281 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order._getStreet | public function _getStreet($street, $line)
{
$street = explode("\n", $street);
if ($line == 1) {
return $street[0];
}
if (isset($street[$line - 1])) {
return $street[$line - 1];
} else {
return '';
}
} | php | public function _getStreet($street, $line)
{
$street = explode("\n", $street);
if ($line == 1) {
return $street[0];
}
if (isset($street[$line - 1])) {
return $street[$line - 1];
} else {
return '';
}
} | [
"public",
"function",
"_getStreet",
"(",
"$",
"street",
",",
"$",
"line",
")",
"{",
"$",
"street",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"street",
")",
";",
"if",
"(",
"$",
"line",
"==",
"1",
")",
"{",
"return",
"$",
"street",
"[",
"0",
"]",
... | Get the street name by line number.
@param string $street
@param int $line
@return string | [
"Get",
"the",
"street",
"name",
"by",
"line",
"number",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L511-L522 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order.expose | public function expose()
{
$properties = array_diff_key(
get_object_vars($this),
array_flip([
'_storeManager',
'helper',
'customerFactory',
'productFactory',
'attributeCollection',
'setFactory',
'attributeSet',
'productResource'
])
);
//remove null/0/false values
$properties = array_filter($properties);
return $properties;
} | php | public function expose()
{
$properties = array_diff_key(
get_object_vars($this),
array_flip([
'_storeManager',
'helper',
'customerFactory',
'productFactory',
'attributeCollection',
'setFactory',
'attributeSet',
'productResource'
])
);
//remove null/0/false values
$properties = array_filter($properties);
return $properties;
} | [
"public",
"function",
"expose",
"(",
")",
"{",
"$",
"properties",
"=",
"array_diff_key",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
",",
"array_flip",
"(",
"[",
"'_storeManager'",
",",
"'helper'",
",",
"'customerFactory'",
",",
"'productFactory'",
",",
"'a... | Exposes the class as an array of objects.
Return any exposed data that will included into the import as transactinoal data for Orders.
@return array | [
"Exposes",
"the",
"class",
"as",
"an",
"array",
"of",
"objects",
".",
"Return",
"any",
"exposed",
"data",
"that",
"will",
"included",
"into",
"the",
"import",
"as",
"transactinoal",
"data",
"for",
"Orders",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L530-L549 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order._getCustomAttributeValue | public function _getCustomAttributeValue($field, $orderData)
{
$type = $field['DATA_TYPE'];
$function = 'get';
$exploded = explode('_', $field['COLUMN_NAME']);
foreach ($exploded as $one) {
$function .= ucfirst($one);
}
$value = null;
try {
switch ($type) {
case 'int':
case 'smallint':
$value = (int)$orderData->$function();
break;
case 'decimal':
$value = (float)number_format(
$orderData->$function(),
2,
'.',
''
);
break;
case 'timestamp':
case 'datetime':
case 'date':
$value = $orderData->$function();
break;
default:
$value = $orderData->$function();
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
return $value;
} | php | public function _getCustomAttributeValue($field, $orderData)
{
$type = $field['DATA_TYPE'];
$function = 'get';
$exploded = explode('_', $field['COLUMN_NAME']);
foreach ($exploded as $one) {
$function .= ucfirst($one);
}
$value = null;
try {
switch ($type) {
case 'int':
case 'smallint':
$value = (int)$orderData->$function();
break;
case 'decimal':
$value = (float)number_format(
$orderData->$function(),
2,
'.',
''
);
break;
case 'timestamp':
case 'datetime':
case 'date':
$value = $orderData->$function();
break;
default:
$value = $orderData->$function();
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
return $value;
} | [
"public",
"function",
"_getCustomAttributeValue",
"(",
"$",
"field",
",",
"$",
"orderData",
")",
"{",
"$",
"type",
"=",
"$",
"field",
"[",
"'DATA_TYPE'",
"]",
";",
"$",
"function",
"=",
"'get'",
";",
"$",
"exploded",
"=",
"explode",
"(",
"'_'",
",",
"$... | Get attrubute value for the field.
@param array $field
@param \Magento\Sales\Model\Order $orderData
@return float|int|null|string | [
"Get",
"attrubute",
"value",
"for",
"the",
"field",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L559-L600 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order._getAttributesArray | public function _getAttributesArray($attributeSetId)
{
$result = [];
$attributes = $this->attributeCollection->create()
->setAttributeSetFilter($attributeSetId)
->getItems();
foreach ($attributes as $attribute) {
$result[] = $attribute->getAttributeCode();
}
return $result;
} | php | public function _getAttributesArray($attributeSetId)
{
$result = [];
$attributes = $this->attributeCollection->create()
->setAttributeSetFilter($attributeSetId)
->getItems();
foreach ($attributes as $attribute) {
$result[] = $attribute->getAttributeCode();
}
return $result;
} | [
"public",
"function",
"_getAttributesArray",
"(",
"$",
"attributeSetId",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributeCollection",
"->",
"create",
"(",
")",
"->",
"setAttributeSetFilter",
"(",
"$",
"attrib... | Get attributes from attribute set.
@param int $attributeSetId
@return array | [
"Get",
"attributes",
"from",
"attribute",
"set",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L622-L634 | train |
dotmailer/dotmailer-magento2-extension | Model/Connector/Order.php | Order.limitLength | private function limitLength($value)
{
if ($this->stringUtils->strlen($value) > \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT) {
$value = mb_substr($value, 0, \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT);
}
return $value;
} | php | private function limitLength($value)
{
if ($this->stringUtils->strlen($value) > \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT) {
$value = mb_substr($value, 0, \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT);
}
return $value;
} | [
"private",
"function",
"limitLength",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stringUtils",
"->",
"strlen",
"(",
"$",
"value",
")",
">",
"\\",
"Dotdigitalgroup",
"\\",
"Email",
"\\",
"Helper",
"\\",
"Data",
"::",
"DM_FIELD_LIMIT",
")"... | Check string length and limit to 250.
@param string $value
@return string | [
"Check",
"string",
"length",
"and",
"limit",
"to",
"250",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Connector/Order.php#L643-L650 | train |
dotmailer/dotmailer-magento2-extension | Observer/Sales/SaveStatusSmsAutomation.php | SaveStatusSmsAutomation.resetContact | private function resetContact($contact)
{
if ($contact->getCustomerId() && $contact->getEmailImported()) {
$contact->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
$this->contactResource->save($contact);
} elseif (! $contact->getCustomerId() && $contact->getIsSubscriber() && $contact->getSubscriberImported()) {
$contact->setSubscriberImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
$this->contactResource->save($contact);
}
} | php | private function resetContact($contact)
{
if ($contact->getCustomerId() && $contact->getEmailImported()) {
$contact->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
$this->contactResource->save($contact);
} elseif (! $contact->getCustomerId() && $contact->getIsSubscriber() && $contact->getSubscriberImported()) {
$contact->setSubscriberImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
$this->contactResource->save($contact);
}
} | [
"private",
"function",
"resetContact",
"(",
"$",
"contact",
")",
"{",
"if",
"(",
"$",
"contact",
"->",
"getCustomerId",
"(",
")",
"&&",
"$",
"contact",
"->",
"getEmailImported",
"(",
")",
")",
"{",
"$",
"contact",
"->",
"setEmailImported",
"(",
"\\",
"Do... | Reset contact based on type and status
@param \Dotdigitalgroup\Email\Model\Contact $contact | [
"Reset",
"contact",
"based",
"on",
"type",
"and",
"status"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Observer/Sales/SaveStatusSmsAutomation.php#L227-L236 | train |
dotmailer/dotmailer-magento2-extension | Observer/Sales/SaveStatusSmsAutomation.php | SaveStatusSmsAutomation.doAutomationEnrolment | private function doAutomationEnrolment($data)
{
//the program is not mapped
if ($data['programId']) {
try {
$typeId = $data['order_id'];
$automationTypeId = $data['automationType'];
$exists = $this->emailAutomationFactory->create()
->addFieldToFilter('type_id', $typeId)
->addFieldToFilter('automation_type', $automationTypeId)
->setPageSize(1);
//automation type, and type should be unique
if (! $exists->getSize()) {
$automation = $this->automationFactory->create()
->setEmail($data['email'])
->setAutomationType($data['automationType'])
->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)
->setTypeId($data['order_id'])
->setWebsiteId($data['website_id'])
->setStoreName($data['store_name'])
->setProgramId($data['programId']);
$this->automationResource->save($automation);
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
} else {
$this->helper->log('automation type : ' . $data['automationType'] . ' program id not found');
}
} | php | private function doAutomationEnrolment($data)
{
//the program is not mapped
if ($data['programId']) {
try {
$typeId = $data['order_id'];
$automationTypeId = $data['automationType'];
$exists = $this->emailAutomationFactory->create()
->addFieldToFilter('type_id', $typeId)
->addFieldToFilter('automation_type', $automationTypeId)
->setPageSize(1);
//automation type, and type should be unique
if (! $exists->getSize()) {
$automation = $this->automationFactory->create()
->setEmail($data['email'])
->setAutomationType($data['automationType'])
->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)
->setTypeId($data['order_id'])
->setWebsiteId($data['website_id'])
->setStoreName($data['store_name'])
->setProgramId($data['programId']);
$this->automationResource->save($automation);
}
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
} else {
$this->helper->log('automation type : ' . $data['automationType'] . ' program id not found');
}
} | [
"private",
"function",
"doAutomationEnrolment",
"(",
"$",
"data",
")",
"{",
"//the program is not mapped",
"if",
"(",
"$",
"data",
"[",
"'programId'",
"]",
")",
"{",
"try",
"{",
"$",
"typeId",
"=",
"$",
"data",
"[",
"'order_id'",
"]",
";",
"$",
"automation... | Save enrolment to queue for cron automation enrolment.
@param array $data
@return null | [
"Save",
"enrolment",
"to",
"queue",
"for",
"cron",
"automation",
"enrolment",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Observer/Sales/SaveStatusSmsAutomation.php#L245-L275 | train |
dotmailer/dotmailer-magento2-extension | Model/Cron/CronSub.php | CronSub.reviewSync | public function reviewSync()
{
//find orders to review and register campaign
$this->orderFactory->create()
->createReviewCampaigns();
//sync reviews
$result = $this->reviewFactory->create()
->sync();
return $result;
} | php | public function reviewSync()
{
//find orders to review and register campaign
$this->orderFactory->create()
->createReviewCampaigns();
//sync reviews
$result = $this->reviewFactory->create()
->sync();
return $result;
} | [
"public",
"function",
"reviewSync",
"(",
")",
"{",
"//find orders to review and register campaign",
"$",
"this",
"->",
"orderFactory",
"->",
"create",
"(",
")",
"->",
"createReviewCampaigns",
"(",
")",
";",
"//sync reviews",
"$",
"result",
"=",
"$",
"this",
"->",
... | Review sync.
@return array | [
"Review",
"sync",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Cron/CronSub.php#L44-L54 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Review.php | Review.sync | public function sync()
{
$response = ['success' => true, 'message' => 'Done.'];
$this->countReviews = 0;
$this->reviews = [];
$this->start = microtime(true);
$websites = $this->helper->getwebsites(true);
foreach ($websites as $website) {
$apiEnabled = $this->helper->isEnabled($website);
$reviewEnabled = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED,
$website
);
$storeIds = $website->getStoreIds();
if ($apiEnabled && $reviewEnabled && !empty($storeIds)) {
$this->_exportReviewsForWebsite($website);
}
if (isset($this->reviews[$website->getId()])) {
$reviews = $this->reviews[$website->getId()];
//send reviews as transactional data
//register in queue with importer
$this->importerFactory->create()
->registerQueue(
\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_REVIEWS,
$reviews,
\Dotdigitalgroup\Email\Model\Importer::MODE_BULK,
$website->getId()
);
//if no error then set imported
$this->_setImported($this->reviewIds);
$this->countReviews += count($reviews);
}
}
if ($this->countReviews) {
$message = '----------- Review sync ----------- : ' .
gmdate('H:i:s', microtime(true) - $this->start) .
', synced = ' . $this->countReviews;
$this->helper->log($message);
$response['message'] = $message;
}
return $response;
} | php | public function sync()
{
$response = ['success' => true, 'message' => 'Done.'];
$this->countReviews = 0;
$this->reviews = [];
$this->start = microtime(true);
$websites = $this->helper->getwebsites(true);
foreach ($websites as $website) {
$apiEnabled = $this->helper->isEnabled($website);
$reviewEnabled = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED,
$website
);
$storeIds = $website->getStoreIds();
if ($apiEnabled && $reviewEnabled && !empty($storeIds)) {
$this->_exportReviewsForWebsite($website);
}
if (isset($this->reviews[$website->getId()])) {
$reviews = $this->reviews[$website->getId()];
//send reviews as transactional data
//register in queue with importer
$this->importerFactory->create()
->registerQueue(
\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_REVIEWS,
$reviews,
\Dotdigitalgroup\Email\Model\Importer::MODE_BULK,
$website->getId()
);
//if no error then set imported
$this->_setImported($this->reviewIds);
$this->countReviews += count($reviews);
}
}
if ($this->countReviews) {
$message = '----------- Review sync ----------- : ' .
gmdate('H:i:s', microtime(true) - $this->start) .
', synced = ' . $this->countReviews;
$this->helper->log($message);
$response['message'] = $message;
}
return $response;
} | [
"public",
"function",
"sync",
"(",
")",
"{",
"$",
"response",
"=",
"[",
"'success'",
"=>",
"true",
",",
"'message'",
"=>",
"'Done.'",
"]",
";",
"$",
"this",
"->",
"countReviews",
"=",
"0",
";",
"$",
"this",
"->",
"reviews",
"=",
"[",
"]",
";",
"$",... | Sync reviews.
@return array | [
"Sync",
"reviews",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Review.php#L100-L145 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Review.php | Review._exportReviewsForWebsite | public function _exportReviewsForWebsite(\Magento\Store\Model\Website $website)
{
$limit = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT,
$website
);
$emailReviews = $this->_getReviewsToExport($website, $limit);
$this->reviewIds = [];
if ($emailReviews->getSize()) {
$ids = $emailReviews->getColumnValues('review_id');
$reviewResourceFactory = $this->reviewResourceFactory->create();
$reviews = $reviewResourceFactory->getMageReviewsByIds($ids);
foreach ($reviews as $mageReview) {
try {
$product = $reviewResourceFactory
->getProductByIdAndStore($mageReview->getEntityPkValue(), $mageReview->getStoreId());
$connectorReview = $this->connectorReviewFactory->create()
->setReviewData($mageReview)
->setProduct($product);
$votesCollection = $reviewResourceFactory
->getVoteCollectionByReview($mageReview->getReviewId());
foreach ($votesCollection as $ratingItem) {
$rating = $this->ratingFactory->create()
->setRating($ratingItem);
$connectorReview->createRating(
$ratingItem->getRatingCode(),
$rating
);
}
$this->reviews[$website->getId()][] = $connectorReview->expose();
$this->reviewIds[] = $mageReview->getReviewId();
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
}
}
} | php | public function _exportReviewsForWebsite(\Magento\Store\Model\Website $website)
{
$limit = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT,
$website
);
$emailReviews = $this->_getReviewsToExport($website, $limit);
$this->reviewIds = [];
if ($emailReviews->getSize()) {
$ids = $emailReviews->getColumnValues('review_id');
$reviewResourceFactory = $this->reviewResourceFactory->create();
$reviews = $reviewResourceFactory->getMageReviewsByIds($ids);
foreach ($reviews as $mageReview) {
try {
$product = $reviewResourceFactory
->getProductByIdAndStore($mageReview->getEntityPkValue(), $mageReview->getStoreId());
$connectorReview = $this->connectorReviewFactory->create()
->setReviewData($mageReview)
->setProduct($product);
$votesCollection = $reviewResourceFactory
->getVoteCollectionByReview($mageReview->getReviewId());
foreach ($votesCollection as $ratingItem) {
$rating = $this->ratingFactory->create()
->setRating($ratingItem);
$connectorReview->createRating(
$ratingItem->getRatingCode(),
$rating
);
}
$this->reviews[$website->getId()][] = $connectorReview->expose();
$this->reviewIds[] = $mageReview->getReviewId();
} catch (\Exception $e) {
$this->helper->debug((string)$e, []);
}
}
}
} | [
"public",
"function",
"_exportReviewsForWebsite",
"(",
"\\",
"Magento",
"\\",
"Store",
"\\",
"Model",
"\\",
"Website",
"$",
"website",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"helper",
"->",
"getWebsiteConfig",
"(",
"\\",
"Dotdigitalgroup",
"\\",
"Em... | Export reviews for website.
@param \Magento\Store\Model\Website $website
@return null | [
"Export",
"reviews",
"for",
"website",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Review.php#L154-L195 | train |
dotmailer/dotmailer-magento2-extension | Setup/Uninstall.php | Uninstall.uninstall | public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$defaultConnection = $setup->getConnection();
$this->dropTable($setup, Schema::EMAIL_CONTACT_CONSENT_TABLE);
$this->dropTable($setup, Schema::EMAIL_CONTACT_TABLE);
$this->dropTable($setup, Schema::EMAIL_ORDER_TABLE);
$this->dropTable($setup, Schema::EMAIL_CAMPAIGN_TABLE);
$this->dropTable($setup, Schema::EMAIL_REVIEW_TABLE);
$this->dropTable($setup, Schema::EMAIL_WISHLIST_TABLE);
$this->dropTable($setup, Schema::EMAIL_CATALOG_TABLE);
$this->dropTable($setup, Schema::EMAIL_RULES_TABLE);
$this->dropTable($setup, Schema::EMAIL_IMPORTER_TABLE);
$this->dropTable($setup, Schema::EMAIL_AUTOMATION_TABLE);
$this->dropTable($setup, Schema::EMAIL_ABANDONED_CART_TABLE);
$this->dropTable($setup, Schema::EMAIL_FAILED_AUTH_TABLE);
$defaultConnection->dropColumn(
$this->getTableNameWithPrefix($setup, 'admin_user'),
'refresh_token'
);
$defaultConnection->delete(
$this->getTableNameWithPrefix($setup, 'core_config_data'),
"path LIKE 'connector_api_credentials/%'"
);
} | php | public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$defaultConnection = $setup->getConnection();
$this->dropTable($setup, Schema::EMAIL_CONTACT_CONSENT_TABLE);
$this->dropTable($setup, Schema::EMAIL_CONTACT_TABLE);
$this->dropTable($setup, Schema::EMAIL_ORDER_TABLE);
$this->dropTable($setup, Schema::EMAIL_CAMPAIGN_TABLE);
$this->dropTable($setup, Schema::EMAIL_REVIEW_TABLE);
$this->dropTable($setup, Schema::EMAIL_WISHLIST_TABLE);
$this->dropTable($setup, Schema::EMAIL_CATALOG_TABLE);
$this->dropTable($setup, Schema::EMAIL_RULES_TABLE);
$this->dropTable($setup, Schema::EMAIL_IMPORTER_TABLE);
$this->dropTable($setup, Schema::EMAIL_AUTOMATION_TABLE);
$this->dropTable($setup, Schema::EMAIL_ABANDONED_CART_TABLE);
$this->dropTable($setup, Schema::EMAIL_FAILED_AUTH_TABLE);
$defaultConnection->dropColumn(
$this->getTableNameWithPrefix($setup, 'admin_user'),
'refresh_token'
);
$defaultConnection->delete(
$this->getTableNameWithPrefix($setup, 'core_config_data'),
"path LIKE 'connector_api_credentials/%'"
);
} | [
"public",
"function",
"uninstall",
"(",
"SchemaSetupInterface",
"$",
"setup",
",",
"ModuleContextInterface",
"$",
"context",
")",
"{",
"$",
"defaultConnection",
"=",
"$",
"setup",
"->",
"getConnection",
"(",
")",
";",
"$",
"this",
"->",
"dropTable",
"(",
"$",
... | Invoked when remove-data flag is set during module uninstall.
@param SchemaSetupInterface $setup
@param ModuleContextInterface $context
@return void | [
"Invoked",
"when",
"remove",
"-",
"data",
"flag",
"is",
"set",
"during",
"module",
"uninstall",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Setup/Uninstall.php#L19-L45 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Connector/Trial.php | Trial._getIframeFormUrl | private function _getIframeFormUrl()
{
$formUrl = \Dotdigitalgroup\Email\Helper\Config::API_CONNECTOR_TRIAL_FORM_URL;
$ipAddress = $this->serverAddress->getServerAddress();
//get the forward ip address for the request
if ($ipAddress) {
$ipAddress = $this->_request->getServer('HTTP_X_FORWARDED_FOR', $ipAddress);
//get the first ip
if (strpos($ipAddress, ',') !== false) {
$ipList = explode(',', $ipAddress);
$ipAddress = trim(reset($ipList));
}
}
$timezone = $this->_getTimeZoneId();
$culture = $this->_getCultureId();
$company = $this->helper->getWebsiteConfig(\Magento\Store\Model\Information::XML_PATH_STORE_INFO_NAME);
$callback = $this->helper->storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true) . 'connector/email/accountcallback';
//query params
$params = [
'callback' => $callback,
'company' => $company,
'culture' => $culture,
'timezone' => $timezone,
'ip' => $ipAddress,
'code' => $this->trialSetup->generateTemporaryPasscode()
];
$url = $formUrl . '?' . http_build_query($params);
return $url;
} | php | private function _getIframeFormUrl()
{
$formUrl = \Dotdigitalgroup\Email\Helper\Config::API_CONNECTOR_TRIAL_FORM_URL;
$ipAddress = $this->serverAddress->getServerAddress();
//get the forward ip address for the request
if ($ipAddress) {
$ipAddress = $this->_request->getServer('HTTP_X_FORWARDED_FOR', $ipAddress);
//get the first ip
if (strpos($ipAddress, ',') !== false) {
$ipList = explode(',', $ipAddress);
$ipAddress = trim(reset($ipList));
}
}
$timezone = $this->_getTimeZoneId();
$culture = $this->_getCultureId();
$company = $this->helper->getWebsiteConfig(\Magento\Store\Model\Information::XML_PATH_STORE_INFO_NAME);
$callback = $this->helper->storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true) . 'connector/email/accountcallback';
//query params
$params = [
'callback' => $callback,
'company' => $company,
'culture' => $culture,
'timezone' => $timezone,
'ip' => $ipAddress,
'code' => $this->trialSetup->generateTemporaryPasscode()
];
$url = $formUrl . '?' . http_build_query($params);
return $url;
} | [
"private",
"function",
"_getIframeFormUrl",
"(",
")",
"{",
"$",
"formUrl",
"=",
"\\",
"Dotdigitalgroup",
"\\",
"Email",
"\\",
"Helper",
"\\",
"Config",
"::",
"API_CONNECTOR_TRIAL_FORM_URL",
";",
"$",
"ipAddress",
"=",
"$",
"this",
"->",
"serverAddress",
"->",
... | Generate url for iframe for trial account popup.
@return string
@throws \Magento\Framework\Exception\LocalizedException | [
"Generate",
"url",
"for",
"iframe",
"for",
"trial",
"account",
"popup",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Connector/Trial.php#L508-L541 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Connector/Trial.php | Trial._getTimeZoneId | private function _getTimeZoneId()
{
$timeZone = $this->localeDate->getConfigTimezone();
$result = '085';
if ($timeZone) {
foreach ($this->timeZones as $time) {
if ($time['MageTimeZone'] == $timeZone) {
$result = $time['MicrosoftTimeZoneIndex'];
}
}
}
return $result;
} | php | private function _getTimeZoneId()
{
$timeZone = $this->localeDate->getConfigTimezone();
$result = '085';
if ($timeZone) {
foreach ($this->timeZones as $time) {
if ($time['MageTimeZone'] == $timeZone) {
$result = $time['MicrosoftTimeZoneIndex'];
}
}
}
return $result;
} | [
"private",
"function",
"_getTimeZoneId",
"(",
")",
"{",
"$",
"timeZone",
"=",
"$",
"this",
"->",
"localeDate",
"->",
"getConfigTimezone",
"(",
")",
";",
"$",
"result",
"=",
"'085'",
";",
"if",
"(",
"$",
"timeZone",
")",
"{",
"foreach",
"(",
"$",
"this"... | Get time zone id for trial account.
@return string | [
"Get",
"time",
"zone",
"id",
"for",
"trial",
"account",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Connector/Trial.php#L548-L561 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Connector/Trial.php | Trial._getCultureId | private function _getCultureId()
{
$fallback = 'en_US';
$supportedCultures = [
'en_US' => '1033',
'en_GB' => '2057',
'fr_FR' => '1036',
'es_ES' => '3082',
'de_DE' => '1031',
'it_IT' => '1040',
'ru_RU' => '1049',
'pt_PT' => '2070',
];
$localeCode = $this->helper->getWebsiteConfig(\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE);
if (isset($supportedCultures[$localeCode])) {
return $supportedCultures[$localeCode];
}
return $supportedCultures[$fallback];
} | php | private function _getCultureId()
{
$fallback = 'en_US';
$supportedCultures = [
'en_US' => '1033',
'en_GB' => '2057',
'fr_FR' => '1036',
'es_ES' => '3082',
'de_DE' => '1031',
'it_IT' => '1040',
'ru_RU' => '1049',
'pt_PT' => '2070',
];
$localeCode = $this->helper->getWebsiteConfig(\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE);
if (isset($supportedCultures[$localeCode])) {
return $supportedCultures[$localeCode];
}
return $supportedCultures[$fallback];
} | [
"private",
"function",
"_getCultureId",
"(",
")",
"{",
"$",
"fallback",
"=",
"'en_US'",
";",
"$",
"supportedCultures",
"=",
"[",
"'en_US'",
"=>",
"'1033'",
",",
"'en_GB'",
"=>",
"'2057'",
",",
"'fr_FR'",
"=>",
"'1036'",
",",
"'es_ES'",
"=>",
"'3082'",
",",... | Get culture id needed for trial account.
@return array | [
"Get",
"culture",
"id",
"needed",
"for",
"trial",
"account",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Connector/Trial.php#L568-L587 | train |
dotmailer/dotmailer-magento2-extension | Controller/Email/Getbasket.php | Getbasket.execute | public function execute()
{
$quoteId = $this->getRequest()->getParam('quote_id');
//no quote id redirect to base url
if (!$quoteId) {
return $this->_redirect('');
}
/** @var \Magento\Quote\Model\Quote $quoteModel */
$quoteModel = $this->quoteFactory->create();
$this->quoteResource->load($quoteModel, $quoteId);
//no quote id redirect to base url
if (! $quoteModel->getId()) {
return $this->_redirect('');
}
//set quoteModel to _quote property for later use
$this->quote = $quoteModel;
if ($quoteModel->getCustomerId()) {
return $this->handleCustomerBasket();
} else {
return $this->handleGuestBasket();
}
} | php | public function execute()
{
$quoteId = $this->getRequest()->getParam('quote_id');
//no quote id redirect to base url
if (!$quoteId) {
return $this->_redirect('');
}
/** @var \Magento\Quote\Model\Quote $quoteModel */
$quoteModel = $this->quoteFactory->create();
$this->quoteResource->load($quoteModel, $quoteId);
//no quote id redirect to base url
if (! $quoteModel->getId()) {
return $this->_redirect('');
}
//set quoteModel to _quote property for later use
$this->quote = $quoteModel;
if ($quoteModel->getCustomerId()) {
return $this->handleCustomerBasket();
} else {
return $this->handleGuestBasket();
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"quoteId",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'quote_id'",
")",
";",
"//no quote id redirect to base url",
"if",
"(",
"!",
"$",
"quoteId",
")",
"{",
"return",
"$",
... | Wishlist page to display the user items with specific email.
@return null | [
"Wishlist",
"page",
"to",
"display",
"the",
"user",
"items",
"with",
"specific",
"email",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Email/Getbasket.php#L60-L86 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.