I need to create a cron script to process products (add, delete, update) when I get them from a raw data file from a third party firm which sends a new file (data separated with ;) whenever a product is changed (added, deleted, updated).
I tried using the Product class (from Product.php) to add new products in the shop. The problem at first was that I got this error :
class 'ObjectModel' not found in importProducts.php
I found an apparent solution, which was to require_once the config and init file from the config folder in importProduct.php :
require_once(dirname(__FILE__).'/../config/config.inc.php');
require_once(dirname(__FILE__) . '/../init.php');
The require points to the right files. My file is located in a new folder, called "crontasks".
prestashop/crontaskt/import.php
(import.php starts importProduct.php)
But now there is a new error :
Fatal error: Uncaught You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
SELECT c.id_category
FROM ps_category_product cp
LEFT JOIN ps_category c ON (c.id_category = cp.id_category)
INNER JOIN ps_category_shop category_shop ON (category_shop.id_category = c.id_category AND category_shop.id_shop = 1)
WHERE cp.id_category NOT IN (18)
AND cp.id_product = thrown in D:\Travail\BUSCI\prestashop\prestashop\classes\db\Db.php on line 791
(they don't appear, but around the query are < br />< br />< pre >...< /pre > without the spaces in it)
Problem is, I checked in the database, and the columns are all there, and I don't get why there is a problem on that line.
Also, I could not find from which file that query was. I looked in Product.php, and I found one very similar but not exactly the same :
$result = Db::getInstance()->executeS('
SELECT c.`id_category`
FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category`)
'.Shop::addSqlAssociation('category', 'c', true, null, true).'
WHERE cp.`id_category` NOT IN ('.implode(',', array_map('intval', $categories)).')
AND cp.id_product = '.$this->id
);
line 1051 in Product.php, method updateCategories.
I could not find anything similar in Category.php or any other file I looked in. But this query is missing the inner join, so I don't know if that's really the one. I suppose the problem comes from the fact that there is nothing after the =, but I don't know if that's just a character limitation (amount of characters printed in an error) or if it is the error. I'm feeling a little lost.
I did not change any files from prestashop. This is the latest update I just installed a week ago on my computer. The tests are done in local, on my computer.
I would really appreciate some help.
Excuse me for my english, it's not amazing.
Edit :
So I searched through the whole project, in every file for the line
INNER JOIN '._DB_PREFIX_.'category_shop
and could not find it. I tried taking away the extra spaces, just in case, but could not find the file in which this sql query is in.
Related
Long story Short: I launched an EC2 instance on AWS to run Dolibarr v13, running PostgreSQL 12.4 on RDS, and Dolibarr itself on Ubuntu 20.04 LTS. All DIY, not Bitnami’s AMI.
Once I started setting up modules on the web app's console, I got this:
Modules/Applications: user, societe, projet, import, export
Database type manager: pgsql
Latest database access request error: SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.rowid as socid, s.nom as socname, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee, COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload FROM llx_projet as p LEFT JOIN llx_societe as s ON s.rowid = p.fk_soc LEFT JOIN llx_projet_task as t ON p.rowid = t.fk_projet WHERE p.rowid IN (-1) GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee ORDER BY p.title, p.ref
Return code for latest database access request error: DB_ERROR_42803
Information for latest database access request error: ERROR: 42803: column "s.rowid" must appear in the GROUP BY clause or be used in an aggregate function\nLINE 1: ...T p.rowid as projectid, p.ref, p.title, p.fk_soc, s.rowid as...\n ^\nLOCATION: check_ungrouped_columns_walker, parse_agg.c:1409
I can’t find anyone else seeing this on the usual sites, but I can’t be the only one. How do I fix this? I’m not well versed in PHP, so I’m not sure where to find the line of code trying to access my DB.
I created two group one is A and other is B . i want there multiple option as each have different prices as acording to customer group i have some code but it does not run properly it give a message as "Call to undefined method Cart\Customer::getCustomerGroupId() in C:\xampp\htdocs\postal\vqmod\vqcache\vq2-catalog_model_catalog_product.php on line 340".
the code is in vqmod xml file -enter code here
problem is there i can not know how to definde customer group id and this code is running in old version perfectly
the code is attach in link -- product-option by download-customer group
please check this and send me how to define and fix the bug.
the code run proper before login- wen i login then give error message.
I suggest to modify system\library\cart\customer.php to:
/create a function/
public function getCustomerGroupId() {
return $this->customer_group_id;
}
I am migrating our wordpress host, and I've attempted the migration using both Wordpress Duplicator and Wordpress All-In-One Migration plug-ins. I am seeing that on the new host, the first post on the main page does not have categories, nor do categories show up when I drill in on them. I do know that they have categories because if I click on a category tab, the post is listed in there.
When I turn php error checking on, I see this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'add_to_byline' not found or invalid function name in /var/www/html/wp-includes/class-wp-hook.php on line 298
I am using a theme called Thesis, which has a function add_to_byline() in
wp-content/themes/thesis_185/custom/custom-functions.php like this:
function add_to_byline() { ?>
</p><p class = "dot_separator">·</p><p class="headline_meta"><?php echo __('', 'thesis') . ' <span>' . get_the_category_list(', ') . '</span>'; ?>
<?php }
add_action('thesis_hook_byline_item', 'add_to_byline', '99');
So add_to_byline() does exist, but somehow the new server host is unable to find it, and as a result isn't displaying the categories.
I've diffed the two versions and they are identical minus some white space differences that resulted from debugging. I've also checked file permissions on both old and new server and they are identical. Does anyone have any idea on how I can go about debugging this further?
So i have installed couple of extensions one of them was fontis feed generator, everything is working fine till i try and access Manage Categories the it comes up with "There has been an error processing your request"
The error is as follows
a:5:{i:0;s:110:"Source model "feedsgenerator/googleproducts_source_taxonomy" not found for attribute "google_product_category"";i:1;s:4101:"#0
Run this sql code to check if there's the attribute causing issues:
select * from eav_attribute where attribute_code = "google_product_category";
If you'll get a result showing the attribute then you should remove it. To do this you can do the following:
Add this to the end of your index.php file:
$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->removeAttribute('catalog_category','google_product_category');
Run the website once with disabled cache (make sure the code run) and then remove the two lines from index.php.
This should be fixed now. You can check if the attribute still exists by running the sql code again:
select * from eav_attribute where attribute_code = "google_product_category";
Sorry if I am not too clear..
Okay so what I have is a web app that shows all the fleet vehicles for my company.I am pulling the information from my database and what I want is to insert and image for the "support van" so that when it is displayed on my app that the image is pulled from the database, I am not sure about Blob data or anything so a clear instruction would be really helpful
here is my master query-Not the "support vans" query ill post that under this one
Maaster-query
SELECT
vi.id as 'VehicleId',
vi.class_type as 'VehicleClass',
vi.registration_number as 'VehicleRegistrationNumber',
vr.role_name as 'VehicleRole',
vm.name as 'VehicleMake',
vmo.name as 'VehicleModel',
ud.name as 'Depot location'
FROM
unify_rebuild.vehicle_information as vi
LEFT JOIN
unify_rebuild.vehicle_role as vr
ON
vi.unit_role = vr.role_id
LEFT JOIN
unify_rebuild.vehicle_manufacturer as vm
ON
vi.make = vm.id
LEFT JOIN
unify_rebuild.vehicle_model as vmo
ON
vi.model = vmo.id
LEFT JOIN
unify_rebuild.unify_depot as ud
ON
vi.depot_current_location = ud.id
and here is the support van query-
SELECT
vi.id as 'VehicleId',
vi.class_type as 'VehicleClass',
vi.registration_number as 'VehicleRegistrationNumber',
vr.role_name as 'VehicleRole',
vm.name as 'VehicleMake',
vmo.name as 'VehicleModel',
ud.name as 'Depot location'
FROM
unify_rebuild.vehicle_information as vi
LEFT JOIN
unify_rebuild.vehicle_role as vr
ON
vi.unit_role = vr.role_id
LEFT JOIN
unify_rebuild.vehicle_manufacturer as vm
ON
vi.make = vm.id
LEFT JOIN
unify_rebuild.vehicle_model as vmo
ON
vi.model = vmo.id
LEFT JOIN
unify_rebuild.unify_depot as ud
ON
vi.depot_current_location = ud.id
WHERE vr.role_name='Support Van';
Any questions please leave a comment and thanks in advance for any help
Calvin
Via your cms you upload images to a folder and take their address and save it in database
and to show that image you take URL from database and in your image source give that URL of the image
I think this link would be helpful for you
How to store file name in database, with other info while uploading image to server using PHP?
Well you can simply record the url of the image into DB as a new row (for ex. vi.imageUrl='http://url-of-image.png').
Then you call that row of the DB and you save it into a variable (you know how to extract values from the DB) for ex: $url_of_img_extracted_from_db is the variable of the image url, then simply you can call it into html with <img src="$url_of_img_extracted_from_db">
I know the code I posted is wrong, it is just an example, you know how to do it ;)