Content Plugin

20.02.2021 06:19
#1
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Content Plugin

To whom it may concern:
I am going to import content articles as article products to be sold by joomshopping component
Do you have a joomla extension in regard to that?
Kian William

 
20.02.2021 08:16
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25919
Quote
Aw: Content Plugin

No.

 
20.02.2021 15:45
#3
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Alright, I shall develop it myself, after being finished and tested would you mind if I send the zip file to learn about your idea about it? the extension will certainly have weak points and strong points and after all the extension relies on joomshopping component
Kian William

 
20.02.2021 16:43
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25919
Quote
Aw: Content Plugin

Ok.

 
20.02.2021 20:28
#5
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Good
Long live science
Kian William

 
03.03.2021 09:55
#6
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

I have not forgotten my promise, before the end of next week I shall send you the files God willing
Kian William

 
06.03.2021 07:38
#7
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Here is the plugin, I tested in Joomla 3.x, there was no problem, I believe it also works in J4 but I have not tested it yet. There are some conditions to work with this plugin :
1- The plugin is designed to work with com_k2 and com_jshopping, it relies on both
2-The user creates the same category structure both in k2 and jshopping, the name must be the same and children in different categories can not have the same name, names must be unique. In the future version, I shall add a system plugin in such a way that as soon as a user creates a category in k2, the same would be created in jshopping automatically but now I am in rush to launch my site and this plugin is just the first step
3-The user must create two extra fields in K2, first one must be for a price under the name field: K2ExtraField_1, second for a short description of the article, the name field K2ExtraField_2, again in future version I shall develop a system plugin to achieve it automatically as soon as the main plugin is uploaded and enabled.
4-I used the manufacturer_id field of table #__jshopping products to add userid of the article writer in k2
5-I used the product_ean field(product code) of table #__jshopping_products to add article id in K2 to the related record
It is easy to alter the table and add these new fields to it but I would rather the integrity of the table remain the same as designed here by you.
6-The plugin works with all languages but category names must be the same as I mentioned before, for example, if a user writes in French and the name of the category in k2 is: La Science, in jshopping this category with the same name must be created.
7-In later versions an article writer could upload a zip file with related images but this one is basic, the user must type or copy and paste the article with images.
Kian William
plg_addarticletojshopping.zip

 
06.03.2021 07:51
#8
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Your technical ideas could assist me to develop and make the plugin better so that it will be good enough to be added in JED.
Kian William

 
08.03.2021 12:58
#9
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Hi admin,
Did you study the plugin? Is it good enough to be uploaded in JED? The reason I am asking is that this extension relies on joomshopping and your idea is important, if you would rather not talk here, you may send your ideas to : webarchitect@kwproductions121.com
Kian William

 
15.03.2021 14:13
#10
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

I did more tests on the plugin, I modified it as:
1-Event must be changed, I employ onContentAfterSave instead of onContentBeforeSave, the cache in the browser prevented me from viewing this mistake.
2-To input images in the article, users would be opened to images folder by clicking image icon, to upload images and then insert their images. To improve more privacy there are different ways, because of having other projects I chose this way:
2-a: I added a plugin to add a folder in images which is the same name as username
2-b: All new users are under publisher group or you can create a group under register and give that group the related actions
2-c: I employed jce editor and made it default editor, in profile section I added images/$username for file directory
So my extension now relys on 3 extensions: 1-jshopping 2-jce-editor 3-k2
now when a user click on image icon in jce-editor of k2 to add an image to article, it will be opened only to his own private folder under images,
3- I wrote french articles and when I checked them in jshopping, french part was added, but the item did not have any name and explanantion,
because the English field was empty, that is why in any language, I fill English fields so that the item product will be editable
I acted so fast for this plugin on account of other projects, I shall do more tests and in case of any change I let you know
Kian William
adduserfoldertojce.zip

 
15.03.2021 14:14
#11
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

Here is the main file, I do not know why the main file is not uploaded by zip, I copy and paste it here:

<?php
defined('_JEXEC') or die;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
use Joomla\String\StringHelper;


class PlgContentAddarticletojshopping extends CMSPlugin
{

protected $autoloadLanguage = true;
protected $db;

public function onAfterInitialise()
{

$this->loadLanguage();
}

public function onContentAfterSave($context, $article, $isNew)
{
$app = Factory::getApplication();
$user = Factory::getUser();
$articlelen= $this->params->get('articlelength');

if($app->isClient('site') && $context==='com_k2.item')
{
$lang = Factory::getLanguage();
$ls = $lang->getTag();

$data = $app->input->post->getArray();


$query="SELECT product_id FROM #__jshopping_products where product_ean = ". $article->id;
$this->db->setQuery($query);
$id= $this->db->loadObject();
$productid = $id->product_id;

if(empty($productid)){




$currencyid = $this->params->get('currencyid');
$taxid = $this->params->get('taxid');
$producttemplate = $this->params->get('producttemplate');
$vendorid = $this->params->get('vendorid');



$itemrec = new stdClass();
$itemrec->product_id = 0;
$itemrec->product_quantity = 1;
$itemrec->unlimited = 0;
$itemrec->product_ean = $article->id;
$itemrec->manufacturer_code = $user->id;

$itemrec->product_date_added= new DateTime($article->created);

$itemrec->product_publish=1;
if(!empty($currencyid))
$itemrec->currency_id=$currencyid;
else
$itemrec->currency_id=1;

if(!empty($producttemplate))
$itemrec->product_template=$producttemplate;
else
$itemrec->product_template='default';




$itemrec->product_price=$data['K2ExtraField_1'];
$itemrec->min_price=$data['K2ExtraField_1'];
$itemrec->product_old_price=0.0;
$itemrec->product_buy_price=0.0;
$itemrec->different_prices=0;
$itemrec->average_rating = 0.0;

$itemrec->add_price_unit_id=1;

$itemrec->delivery_times_id=0;
$itemrec->weight_volume_units=0.0;
$itemrec->product_weight=0.0;

$itemrec->basic_price_unit_id = 1;

if(!empty($vendorid))
$itemrec->vendor_id=$vendorid;
else
$itemrec->vendor_id= 1;


if(!empty($taxid))
$itemrec->product_tax_id=$taxid;
else
$itemrec->product_tax_id= 1;



$itemrec->label_id=0;

$itemrec->{"meta_keyword_".$ls} = $article->metakey;
$itemrec->{"meta_description_".$ls} = $article->metadesc;
$itemrec->{"alias_".$ls}=$article->alias;

if($ls!=="en-GB"){
$itemrec->{"name_en-GB"}=$article->title;
$itemrec->{"short_description_".$ls}=$data['K2ExtraField_2'];
$itemrec->{"description_".$ls}=StringHelper::substr( $article->introtext,0, $articlelen )."...";
}




$itemrec->different_prices = 0;
$itemrec->product_manufacturer_id = 0;
$itemrec->product_is_add_price = 0;
$itemrec->average_rating = 0;
$itemrec->reviews_count= 0 ;
$itemrec->hits = 0;
$itemrec->access = 1;

$itemrec->{"name_".$ls}=$article->title;

$itemrec->{"short_description_".$ls}=$data['K2ExtraField_2'];
$itemrec->{"description_".$ls}=StringHelper::substr($article->introtext, 0, $articlelen )."...";

// $itemrec->{"description_".$ls}=$article->introtext;


if($ls!=="en-GB"){
$itemrec->{"name_en-GB"}=$article->title;
$itemrec->{"short_description_en-GB"}=$data['K2ExtraField_2'];
$itemrec->{"description_en-GB"}=StringHelper::substr( $article->introtext,0, $articlelen )."...";
}

$result = $this->db->insertObject('#__jshopping_products', $itemrec, 'product_id');
var_dump($result);

if($result==1)
{
$query = $this->db->getQuery('true');
$query="SELECT product_id FROM #__jshopping_products Order By product_id Desc";
$this->db->setQuery($query);
$id= $this->db->loadObject();
$lastproductid = $id->product_id;


$query = $this->db->getQuery('true');
$query
->select(array('a.category_id', 'b.name'))
->from($this->db->quoteName('#__jshopping_categories', 'a'))
->join('INNER', $this->db->quoteName('#__k2_categories', 'b') . ' ON ' . $this->db->quoteName('a.name_en-GB') . ' = ' . $this->db->quoteName('b.name'))
->where($this->db->quoteName('b.id') . ' = ' . $this->db->quote($article->catid));

$this->db->setQuery($query);
$r = $this->db->loadObject();


$query = $this->db->getQuery('true');
$columns = array('product_id', 'category_id', 'product_ordering');
$values = array( $this->db->quote($lastproductid), $this->db->quote($r->category_id), 1);
$query
->insert($this->db->quoteName('#__jshopping_products_to_categories'))
->columns($this->db->quoteName($columns))
->values(implode(',', $values));
$this->db->setQuery($query);
$this->db->execute();



}



}else{
$query = $this->db->getQuery('true');
$query="SELECT product_id FROM #__jshopping_products where product_ean = ". $article->id;
$this->db->setQuery($query);
$id= $this->db->loadObject();
$productid = $id->product_id;
$itemrec = new stdClass();
$itemrec->product_id = $productid;

$itemrec->date_modify= new DateTime($article->modified);

$itemrec->product_price=$data['K2ExtraField_1'];
$itemrec->min_price=$data['K2ExtraField_1'];
$itemrec->{"meta_keyword_".$ls} = $article->metakey;
$itemrec->{"meta_description_".$ls} = $article->metadesc;
$itemrec->{"alias_".$ls}=$article->alias;
$itemrec->{"name_".$ls}=$article->title;
$itemrec->{"short_description_".$ls}=$data['K2ExtraField_2'];
$itemrec->{"description_".$ls}=StringHelper::substr($article->introtext,0, $articlelen )."...";
if($ls!=="en-GB"){
$itemrec->{"name_en-GB"}=$article->title;
$itemrec->{"short_description_en-GB"}=$data['K2ExtraField_2'];
$itemrec->{"description_en-GB"}=StringHelper::substr( $article->introtext,0, $articlelen )."...";
}


$result = $this->db->updateObject('#__jshopping_products', $itemrec, 'product_id');






}

}

return true;
}

}
In case of any question or new ideas just let me know
Kian William


Last change: 15.03.2021 14:16
 
15.03.2021 14:21
#12
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

trying once again to upload zip file, no success! In case you need the complete package email me and I shall send it
webarchitect@kwproductions121.com
Kian William


Last change: 15.03.2021 14:25
 
21.03.2021 08:35
#13
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

My extension is enlisted in JED(joomla extension directory), unfortunately, you did not favour us with your professional ideas to make it better, yet I still thank you for the remarkable extension joomshopping. I admire that
Long live Science
Kian William


Last change: 21.03.2021 08:36
 
11.05.2021 11:49
#14
KianWilliam121
Joomshopping forum user no avatar
Name: Kian William
19.10.2015
Posts: 70
Quote
Aw: Content Plugin

To make this plugin better I actually am adding another plugin to its package in such a way that if a user register or update profile by com_jshopping or register or update in com_k2 , the both sides become updated. it is only for the base fields that com_jshopping have considered in the registration and update form which is enough for the business and shop online. Yet in a future version, all possible optional fields both in com_jshopping and com_k2 shall be considered.
Kian William

 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.